Search code examples
gitgit-resetgit-add

Can we restore the files that were removed by a reset if they are staged?


In general, we can restore all the objects that are stored as commits even if they are reset by using reflog. As I understand it, this is because they work with the git objects present in the .git directory. So, is it possible to restore files if they are staged? Since, blobs will be created for the files when they are staged.

DETAILED EXPLANATION: I have made several changes to my repository and I have staged them. Now, I wanted to remove the unstaged changes but instead I reset the entire repository thereby losing all the changes made. I want to recover only the staged changes.

When I staged the files blogs would have been created..will it be possible for me to find out the blobs and recover them(the changes)?


Solution

  • Well, likely, technically the changes are still there. The only problem that they're only known by their hashes (which you don't know, obviously). So without a known reference, even "weak", such a reference from reflog you don't have a method to pick them up. So, my guess, you can't resurrect them anymore, sorry.