You can revert ant code you have in your local git folder, whether its was committed or not.
What can be recovered:
- All commited changes
- All added items (git add without git commit)
- All loose blobs (dangling files)
What can't be recovered:
- Deleted files from the local file system. (You can recover those by using 3rd party tool which scan your drive and recover them)
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.