How to reuse pending comments after git commit fail?

I use an external editor to populate the comments for "git commit", if for some reason the commit fails, all comments disappear. Is there a place where my commit comments are stored which could not be saved?

Is there any specific git command to reuse such pending comments or re-commit with pending comments?

+4
source share
1 answer

When editing a comment, you can save the contents of the editor in a file somewhere, say message.txt. If for some reason the commit failed, you can reuse the file as follows:

git commit -F message.txt

If you did not save the message before exiting the editor, and the commit failed, it disappeared forever.

Btw, note that the commit message editor contains the following:

# 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 that you saved, and then you use this file later with -For flags --file, then these lines will be included in the commit message. Therefore, you will want to clean them or not save them first.

UPDATE

, , .git/COMMIT_EDITMSG, . :

git commit -eF .git/COMMIT_EDITMSG
+2

All Articles