Git hangs with "hint: Waiting for your editor to close the file..." when closing a commit message file in VSCode

Viewed 28624

I'm running git commit --amend in the VSCode terminal and it pops up the commit message as a file in the VSCode editor window, and git says (in the terminal) hint: Waiting for your editor to close the file... but doesn't give input back yet.

I amend my changes, then save and close the file. Then git just sits there in the terminal like it didn't know the editor window closed. Does VSCode cling onto the file handle longer than it needs to?

It looks like it's not a path issue because I can start and finish the commit amend (note I'm using keyboard shortcuts to do my initial commits, so that doesn't open an editor - I only noticed this on an amend).

2 Answers

I see a similar issue here on Github.

  1. If you use editor = code --wait in .gitconfig, you have to close VS Code (not the .git/COMMIT_EDITMSG file) to correctly commit.

  2. Add editor = code --wait -n in your .gitconfig file. I think -n here means a new instance of VS Code.

  3. After finishing the config, you type git commit in VS Code terminal, a new VS Code windows will pop up. Just edit your message in COMMIT_EDITMSG in the new windows

Alternatively use a -m "your commit comment" argument do directly give the commit message and avoid git opening an editor.

Related