12

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

AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173

3 Answers3

10

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

Devon Ge
  • 109
  • 2
  • This works but like it suggests, it just opens a whole new window, which is not desirable. – AncientSwordRage Oct 31 '18 at 18:40
  • 1
    Yes. When deleting `--wait` in the config file, the file is open in the same window, but the command line hint is skipped.(also undesirable). I have no better solution for now – Devon Ge Nov 01 '18 at 13:17
  • 1
    The VS Code October 2018 (version 1.29) updates some terminal features. This issues should be fixed now. – Devon Ge Nov 13 '18 at 11:00
  • I don't see any details on the [1.29 Updates](https://code.visualstudio.com/updates/v1_29) page to do with 'git' or 'wait'. Do you know where the details are? – AncientSwordRage Nov 13 '18 at 13:25
6

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

0

The same can happen if you have two versions of VS code running on your machine.

  • 2
    until you say how to solve the problem, this is not an answer. – starball May 10 '23 at 22:27
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/34367565) – Guildenstern May 12 '23 at 20:00