DEV Community

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

Meg Gutshall on October 15, 2018

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 co...
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

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
 
meg_gutshall profile image
Meg Gutshall • Edited

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
 
iambryanhaney profile image
Bryan Haney

Had the same problem using zsh. Same fix, but the file is .zprofile

Collapse
 
meg_gutshall profile image
Meg Gutshall

Thanks for the comment Bryan! We're covering all the bases here! 😃

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

I tried this out but no luck. Thanks anyway!

Collapse
 
valverde667 profile image
Nick Valverde

This worked for me if anyone else scrolls this far done.
For thoroughness, I use atom so in my .gitconfig it reads

[core]
editor = atom -w

Collapse
 
wolf5996 profile image
Badran Elshenawy

Hi there,
Thank you for all the advice. I have looked at all the suggestions, and I have checked my .gitconfig file: editor = atom -w is set correctly, yet I still have the same issue.

Thread Thread
 
meg_gutshall profile image
Meg Gutshall

Hey Badran! Can you take a screen shot of your .gitconfig file? (Obviously, blur out the sensitive info.) Also what operating system are you on?