Undo Any Git Action ⎌
git reflog
is a record of your commands in Git. With it, you can undo almost anything.
$ git reflog
4bd0090 HEAD@{0}: <bad change>
46bd839 HEAD@{1}: <bad change>
967e214 HEAD@{2}: <last good change>
46bd839 HEAD@{3}: <good change>
967e214 HEAD@{4}: <good change>
Reset your branch to its reference name:
$ git reset --hard HEAD@{2}
Or reset it to the SHA:
$ git reset --hard 967e214
Tweet