Recovering added/staged file after doing git reset –hard HEAD^?


I added a new file F1 and made changes to another file F2 but then did a git reset --hard HEAD^ and I have lost all the changes to the files.

Is there some way, I can get them back?

I did look at a related question here: How can I undo git reset –hard HEAD~1? but, that question assumes that the one has done a Git commit.


You can (with some work) recover state of file at the last "git add <file>". You can use

$ git fsck --cache --no-reflogs --lost-found --dangling HEAD

and then examine files in ‘.git/lost-found/other’ directory.

Please read git fsck manpage.

Answered By – Jakub NarÄ™bski

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published