0

I'm working on a git repository using git-scm.

While choosing unstaged files to commit, my laptop abruptly shut down due to low battery. After restart, all my unstaged changes were gone even if the changes were still there in files.

Any solution for this?

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Brian Pham
  • 551
  • 9
  • 23
  • 1
    Can you clarify what you mean with "all my unstaged changes were gone even if the changes were still there in files", what is the result of `git status`? – joran Aug 03 '15 at 19:16
  • What about `git diff --cached` , do you see what you're looking for ? – topheman Aug 03 '15 at 19:40
  • I mean the list of unstagged changes doesn't show up in Git GUI but actually the changes are still there and were not reverted. – Brian Pham Aug 04 '15 at 03:14
  • both git diff --cached and git status return error: bad signature fatal: index file corrupt – Brian Pham Aug 04 '15 at 03:14

1 Answers1

1

You may need to rebuild the index and start over from the last commit:

rm -rf .git/index
git reset

This should leave you with your changes in the working tree and with an "empty" index.

I recomend that you do a backup before doing this.

joran
  • 2,815
  • 16
  • 18