gitvisual-studio-code

How can I cancel a git commit while VS Code is waiting for the commit message in an editor tab?


I'm testing the Visual Studio Code's source control, and I recklessly hit the "Commit" button; now it's waiting for me to enter the commit message:

Enter image description here

It is like a loading or waiting motion. It's waiting for me to enter the commit message.

Is there a way to cancel and terminate the whole commit process in this situation?


Solution

  • I just want to point out that the message itself (the one in the editor, and which is shown in your screenshot) is pretty instructive, though maybe not obvious:

    an empty message aborts the commit.

    Close the editor tab with an empty message (no need to touch the commented lines). You can close the commit message editor tab using ctrl/cmd+w, or middle click the tab handle, or click the "x" button on the tab handle.

    The same goes for any other commit message editor program other than VS Code. Ex. vim or whatever you've configured as your default commit editor. I'm pretty sure it's just how Git itself processes commit messages from a file- not specific to any editor like VS Code.


    Related readings if you want to learn deeper: git commit --template, How to specify a git commit message template for a repository in a file at a relative path to the repository?, What is VS Code's "new git grammar" in the v1.76 release notes?.