How to abort 'git commit --amend'?
If you delete the commit message (no need to delete the ones starting with #
) you will abort the git commit --amend
command. You will get output like this:
Aborting commit due to empty commit message.
That is correct. Saving the file with no contents will abort the amend.
Adding another answer to this, you can also do
:cq
to abort the amend in Vim which tells it to quit with an error code, causing Git to abort with:
error: There was a problem with the editor 'Vim'.
Please supply the message using either -m or -F option.
From Vim's documentation:
:cq[uit][!] Quit Vim with an error code, so that the compiler
will not compile the same file again.
WARNING: All changes in files are lost! Also when the
[!] is not used. It works like ":qall!" :qall,
except that Vim returns a non-zero exit code.
delete the message. an empty message will abort any commit (amend is just a 'special' commit)