How to reuse pending comments after git commit fail?
While editing the comment, you can save the content of the editor in a file somewhere, let's say message.txt
. If the commit fails for some reason then you can reuse the file like this:
git commit -F message.txt
If you didn't save the message before exiting the editor and the commit failed, it's gone forever.
Btw, note that the commit message editor contains like these:
# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.# Explicit paths specified without -i nor -o; assuming --only paths...# ...
If you included this text in the message file you saved, and then you use this file later with the -F
or --file
flags, then these lines will be included in the commit message. So you will want to clean them up, or not save them in the first place.
UPDATE
As You discovered yourself, it seems the last commit message is saved in .git/COMMIT_EDITMSG
even if the commit failed. So you can reuse it with the command:
git commit -eF .git/COMMIT_EDITMSG