How do I commit a git message in IntelliJ's terminal?

Viewed 1296

When committing my changes to git using the IntelliJ terminal and a message is prompted, how do I then save that message and complete the commit?

Since it's using vim the usual approach is to hit esc and then type :wq to save and quit. However hitting esc just retargets the window I was viewing before (in this case the code file).

Is there a different way to save these files when using the built in terminal?

Thanks.

4 Answers

The default key binding in IntelliJ IDEA for switching focus from the integrated terminal to the editor is ESC. You can change this binding in the following way:

  1. Open settings (Windows) or preferences (MacOS)
  2. Navigate to Tools > Terminal
  3. Click on Configure terminal keybindings behind the checkbox Override IDE shortcuts
  4. Change or remove the key binding for Plugins > Terminal > Switch Focus To Editor

I had the same issue for a few days and I finally found a solution, on Win10 it's Ctrl + c, then you quit editing mode. You can then type :x! to save commit message and quit Vim.

Other answers already explained how you can do it within the UI. But you can avoid opening vim by passing the commit message as an argument to git commit command within intellij built in terminal.

git commit -m "Some commit message"

Intellij navbar

You should click on the magnifying glass and type commit.

Then the commit box opens. Type your message and commit. Commit box on intellij

Related