Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Undo git commit --amend [duplicate]

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.

like image 476
Nir Duan Avatar asked Dec 06 '25 03:12

Nir Duan


1 Answers

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"

like image 58
Kalecser Avatar answered Dec 08 '25 16:12

Kalecser