Search code examples
gitunstage

Unstaged changes left after abrupt shut down


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?


Solution

  • 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.