Last Updated: May 11, 2016
·
36.74K
· dsci

Git: Undo git reset

If you did something like

git reset HEAD~1

sometime you want to undo this. There is no need to cry, Git keeps a log of all ref updates.

To see them:

git reflog

The output may something like that

39ab761 HEAD@{0}: reset: moving to HEAD~1
b55c098 HEAD@{1}: Change skirt length ...

With

git reset HEAD@{1}

we undo our mistake and we are back at the commit before reseting.

Also possible:

git reset b55c098