How to Undo git commit --amend

时间:2016-08-31 12:30:18

标签: git git-commit git-rewrite-history

I've accidently did git commit --amend on the last commit on the tree (which is not written by me ) and I would like to undo this commit and retrieve my changes back to the working directory.

I'm familiar with the fact the --commit amend is part of "Rewriting History" Git commands but I hope there is a workaround via author name or any other.

1 个答案:

答案 0 :(得分:2)

Yes, there is a way to recover your state prior to the amend. Go to the working copy and run git reflog, find the hash of the commit prior to the amend and do a git reset to it. You are done ;)

Duplicate of: How to undo "git commit --amend" done instead of "git commit"