Search code examples
gitgit-gui

Recover changes from aborted git commit


I started Git Gui, clicked Ctrl+I to stage all the modified files, typed a text message and clicked Commit. An error message saying that an Excel file was locked appeared asking whether to try again or stop.

I think I clicked the stop button (not sure), Git Gui closed, I closed the Excel file, and now most of my files are gone.

There were about 6-7 staged files, and now 30-40 files are missing.

Not only do I miss the files modified in the last 2-3 days, I miss also many other files. I think I can recover the old files by checking out the last commit, but how do I restore the changes of the last 2-3 days?


Solution

  • I assume there was a git add ... done at some point since you were trying to commit, so you should be able to recover these files since git does save added files (staged but uncommitted) as well as committed files. Try running git fsck --lost-found and it will output the folder of where it found lost & found files. Good luck.