How can I prevent git bash vi from crashing while rewording commit message with interactive rebase?

78 Views Asked by At

I am getting the below error message while attempting to reword a commit in git bash using vi/vim. I have tried on IntelliJ terminal and Git Bash terminal itself with the same result.

hint: Waiting for your editor to close the file... Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

Program is C:\Program Files\Git\bin\bash.exe.

bash --version
GNU bash, version 5.2.15(1)-release (x86_64-pc-msys)

I want to reword the commit message of hash1

git log
---

commit <hash1>
  # ...

commit <hash2>
  # ...

I use git rebase -i to attempt. Git opens vi so I can specify the rebase options. I press i to enter insert mode, type 'reword', and then press ctrl+c to enter command mode. I press :wq to save and quit.

git rebase -i <hash2>
---

reword <hash2> <message>

Git opens COMMIT_EDITMSG in vi. I press i to enter insert mode. I type the new message. I press ctrl+c to enter command mode and -- instead of entering command mode, vi crashes.

hint: Waiting for your editor to close the file... Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

I have tried the following git config --global core.editor settings recommended in a similar SO post:

  • null
  • vi
  • vi -f
  • vim
  • vim -f

I am able to recover using vi .git/COMMIT_EDITMSG and restoring the swp file, but I shouldn't have to. Thanks in advance for any help you can offer in saving me from having to use notepad++ as my editor.

0

There are 0 best solutions below