Posted over 9 years ago. Visible to the public. Linked content.

How to fix a corrupt git index

If your git index for some reason becomes invalid, no need to worry.

Your index is corrupt when you see this error running usual git commands like git pull, git status, etc.:

Copy
error: bad index file sha1 signature fatal: index file corrupt

Though it sounds bad, your changes are still there. Fix it by first removing the index file, then resetting the branch:

Copy
rm .git/index git reset

You should be all good now.

To be safe, make a backup of .git/index before you delete it.

Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
about 9 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more