Is there any way to undo the effects of "git get my head back"?

I accidentally run a command against the wrong branch in my repository - is there a way to undo this change?

+64
git undo revert
Sep 07 '10 at 20:40
source share
3 answers

git revert just creates a new commit - you can β€œdelete” it with git reset --hard HEAD^ (be careful with it!)

+93
Sep 07 '10 at 20:41
source share

The git revert command simply creates a commit that cancels another. You have to run git revert HEAD again and this will undo the previous undo and add another commit for this. Or you can do git reset --hard HEAD~ . But be careful with this last one when it deletes data.

HEAD~ means commit before the current HEAD

+26
Sep 07 2018-10-09T00:
source share

How about return refund?

Check the git log and get a bad return hash:

git log -5

Then cancel the self-healing:

git revert

+3
Sep 25
source share



All Articles