0

I had some changes in my local branch which I added using git add -A. Then for some reasons I unstaged these changes by doing git reset. Then I opened GitExtensions and clicked on Reset all changes. (I somehow assumed that it was Reset selected changes :/)

So I ended up losing these changes. Is it possible to recover these changes given that they were once added ?

The conversation here suggests that the changes can be recovered if they were ever staged. I could not find how though: need to undo "Reset Changes" action git extensions

I found ways to recover if the changes were once stashed: how-to-recover-a-dropped-stash-in-git

The answers here suggest that it is not possible to recover the changes if they are not commited, staged, or stashed: accidentally-reverted-to-master-lost-uncommitted-changes

Ajinkya
  • 1,231
  • 1
  • 9
  • 10
  • 4
    I didn't know this, but it seems it [might be possible](https://stackoverflow.com/questions/11094968/in-git-how-can-i-recover-a-staged-file-that-was-reverted-prior-to-committing) to recover your files, assuming you did in fact stage them. If you really never staged anything and wiped out your working directory, then you're probably out of luck. One exception: If you had the files open in a good IDE, like IntelliJ, then it (i.e. the IDE) might maintain its own local history which you could use to revert. – Tim Biegeleisen May 31 '18 at 05:59

1 Answers1

0

Yes, that's possible because the content of the files is added to the git repository when you stage the files. But you won't recover the file name because tree objects are only created when committing.

There is a "recover lost objects" feature in Gitextensions for that: https://git-extensions-documentation.readthedocs.io/en/latest/maintenance.html#recover-lost-objects

Note anyway that the doc is not up to date and that the menu entry has been moved (it is in the "repository" menu now).

Ps: And I highly advise you to use the development version of the next version to be released for at least recover your files because I have improved the feature to make a lot easier the recovery of files in your special case. You could download it here: https://ci.appveyor.com/project/gitextensions/gitextensions/branch/master/artifacts

Then I opened GitExtensions and clicked on Reset all changes. (I somehow assumed that it was Reset selected changes :/)

The "Reset selected changes" is when right click on the selected files or using the "r" keyboard shortcut.

Philippe
  • 28,207
  • 6
  • 54
  • 78