My uncommitted files deleted by git reset --hard
command. How can I recover? I tried git reflog
etc but it stays at 0%.
Checking object directories: 100% (256/256), done.ories: 0% (1/256)
My uncommitted files deleted by git reset --hard
command. How can I recover? I tried git reflog
etc but it stays at 0%.
Checking object directories: 100% (256/256), done.ories: 0% (1/256)
If you have staged your file, you can try git fsck --lost-found
then take a look into .git/lost-found/other
and using git show <SHA>
check what you can recover
So I've recreated your scenario: (created new_file
then stage it, and git reset --hard
afterwards)
Checked the content of .git/lost-found/other
Then recover the content git show <SHA>
:
Fortunately in my case I had a small number of commits so it was easy to find it.
For staged file, you can check the output in git fsck, but for private files, as in not even staged (
git add
), then those files are gone.git reflog
would only help to restore past commits.Double-check with: