I just made a huge accident. I wanted to undo a local commit and I ran git reset --hard HEAD~1
. However I had many uncommited files (about two days of work).
All the uncommited changes have been reset too.
Help!
How do I undo a git reset --hard HEAD~1
?
You can revert ant code you have in your local git folder, whether its was committed or not.
What can be recovered:
What can't be recovered:
How to recover:
First run git reflog
ro git log -g
to verify what did you clean. Then checkout the commit that you wish to recover.
Now you have to recover added but uncommited files. To find those files run git fsck
and it will print out the dangling files. use git cat-file -p <SHA1>
to print them out to screen and then recover them.
git log -g
will display the reflog entry for each of your commit.
Good luck.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments