Friday, April 5, 2013

How to revert a git reset --hard

If you ever did a
git reset --hard <SHA>
by mistake, there is hope to recover your work, even if you didn't push your changes to remote before the reset.

Type the following in terminal:

git reflog   
- this will show a list of the last places where the HEAD were; you'll see your reset command(s) too

git reset --hard <SHA> 
- here you'll write the SHA corresponding with the line just before the reset command(s)

Here you go, your work magically appears.


No comments:

Post a Comment