Last Updated: November 21, 2022
·
58.79K
· 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

1 Response
Add your response

@daniel schmidt
I don't think this works as you mentioned
resetting to particular commit from reflog works

but git reset HEAD@{1} after doing git reset HEAD~1, doesn't make sense to me
and didn't undo the reset

over 1 year ago ·