I’m trying to set up git so that the vim editor opens when I do git commit
without a message. Previously I had set up VSCode do this, but it wasn’t working, it was giving me the error "aborting due to empty message" before opening VSCode. I then see a COMMIT_EDITMSG file in VSCode for me to edit, but editing and saving it does not cause the commit to go through.
I tried to change the editor to vim instead, entering git config --global "vim -w
and git config --global core.editor vim
based on other StackOverflow answers. git config --get core.editor
confirms that git is now configured to use vim as the editor. But git commit
still aborts before I can enter a commit message, and then opens VSCode. I’d rather just go back to using vim than try to fix whatever is going on in VSCode, since I prefer vim.
2
Answers
Per discussion in comments, the cause of the problem was
GIT_EDITOR
had been set tocode
, and the solution wasunset GIT_EDITOR
.There are several places git looks for the editor to use, this is explained well in git-var manpage:
As you have discovered, you had
GIT_EDITOR
set and that is considered beforecore.editor
.