2

A pretty frequent scenario for me is writing a long, thoughtful commit message, then fat-fingering my smartcard PIN.

% git commit
error: gpg failed to sign the data
fatal: failed to write commit object

After this when running git commit again the message is lost. Is there a way to have Git remember the previous message?

1

1 Answer 1

3

The best solution I have found so far is that after a failed commit (actually after any commit) the commit message file (including any extra info that would be stripped from the message) is left over in .git/COMMIT_EDITMSG. You can save that file before running the next git commit and paste it into the new message.

Note that this file will be overwritten as soon as you run git commit another time. So be sure to save it before starting the second commit attempt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .