DEV Community

Cover image for How to fix "fatal: .git/index: index file smaller than expected" git error
Stephen Akugbe
Stephen Akugbe

Posted on

How to fix "fatal: .git/index: index file smaller than expected" git error

I was recently working on a project and as I was trying to commit my changes, I saw this error message and I didn't understand why it happened, I decided to investigate why it happened and discovered it was because the index file was corrupt.

The index file gets corrupted due to the following reasons:

  • You terminal process was stopped midway
  • Your system has run out of disk space
  • You used a symlink to the git folder to create directories to use for building in place of svn externals
  • Or for some other reason that might not be explained here

.git/index: index file smaller than expected - git error

To fix it I simply removed the corrupted index file using this command

rm .git/index

Once this has been done, the files can then be re-staged and the error is fixed.

Top comments (0)