levelnis
levelnis

Reputation: 7705

How to retrieve previous git commit message changed by amend

This has probably been asked before so if it has, please point me to the explanation. I'm using the Git source control plugin for Visual Studio and have half-written a commit message.

There's an Amend last commit button, which retrieves the previous commit message if you haven't entered anything for the current commit message. If you have entered something, it changes the previous commit message to the text you have entered for the current commit message and commits that automatically for you. Not what I wanted.

Can I see what the commit message of the previous commit was BEFORE the Amend command changed it? I just want to do the same thing again in reverse to flip the previous commit message back.

Upvotes: 1

Views: 239

Answers (1)

Ryan LaNeve
Ryan LaNeve

Reputation: 1244

From a command line, you can use git reflog to find the SHA of the initial version of the commit (i.e., the one with the original commit message). Once you have the SHA, you can run:

git show <SHA>

That will show you the details of the commit, which includes the commit message.

Upvotes: 5

Related Questions