简体   繁体   中英

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.

From a command line, you can use git reflog to find the SHA of the initial version of the commit (ie, 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM