loading...

Git commit aborts before I can create a commit message and I use “--wait”

meg_gutshall profile image Meg Gutshall ・1 min read

I use Visual Studio Code on my Mac as my text editor and have it set up to open a new window to type my commit message, however when I type 'git commit' in the terminal, it instantaneously displays 'Aborting commit due to empty commit message.'

I have my git config set up as 'git config --global core.editor "code --wait"' and when I type 'git config --global -e' it shows '[core] editor = code --wait'. I've uninstalled and reinstalled git, I've went through the VS Code as Git Editor setup guide, and have searched online for a solution for at least ten hours. My git and VS Code versions are up to date and my commits work when I type 'git commit -m "message here"' in the command line, but I still don't know why my VS Code editor option isn't working.

Any ideas here? Thank you!

Discussion

pic
Editor guide
Collapse
cvega profile image
Casey Vega

If you're using the command line to handle your commits you may want to try exporting your EDITOR.

$ export EDITOR="$(which code) --wait"

You can validate the export

$ echo $EDITOR
/usr/local/bin/code --wait

I prefer vim for editing, however, I do use vscode from time to time. I only ran the following commands above and was able to end up here. Hopefully, this works for you.

vscode-commit

Collapse
meg_gutshall profile image
Meg Gutshall Author

This didn't work either. I think I may have downloaded something that's interfering...

Collapse
cvega profile image
Casey Vega

You can also use the built-in functionality.

vscode-commit

Collapse
chijos profile image
Chirag Joshi

You may have already tried this, but does running code --wait directly work. Also try changing the editor setting to code --disable-extensions --wait to see if that helps.
It might be that the editor is crashing for some reason and returning an empty commit message.

Collapse
meg_gutshall profile image
Meg Gutshall Author

I tried this out but no luck. Thanks anyway!

Collapse
meg_gutshall profile image
Meg Gutshall Author

Got an idea from Stackoverflow -- I figured out how to edit my environment variables by typing open .bash_profile in the terminal and sure enough, my default didn't have the --wait flag on it. I'm attaching a screenshot for visual people.

Screenshot of solution

Collapse
leettaylor profile image
Lee Taylor

Just in case anyone else ends up here from a search here's the solution I found (For Ubuntu):

Inside of my .gitconfig I added the following line:

[core]
    editor = code -w