vertis.io

git: fatal: index file smaller than expected

Introduction

user

Luke Chadwick

Geek since birth. Futurist. Lover. Idealist.


git: fatal: index file smaller than expected

Posted by Luke Chadwick on .
Featured

git: fatal: index file smaller than expected

Posted by Luke Chadwick on .

NB: You should back up your working directory before trying anything in this post.

$ git status
fatal: index file smaller than expected
$ git reset --hard
fatal: index file smaller than expected

Uh-Oh-Spaghetti-O’s. Not a nice error message to get first thing in the morning. After much googling I realized that the .git/index is only used to track staged and unstaged changes. So the simplest way out of this mess is to move the broken index out of the way.

$ mv .git/index .git/index.backup
$ git status

You should now be presented with a rather confused view of the working tree, where it thinks things have been deleted and there is a whole raft of untracked files…

$ git add .

And we’re back to where we should be.

user

Luke Chadwick

http://vertis.io

Geek since birth. Futurist. Lover. Idealist.