This morning, I started getting this error from git:
fatal: index file smaller than expected
fatal: git status --porcelain failed
To those having isses even after removing index and cannot do a reset. If you want to keep your changes do the following (not a solution but rather an ugly workaround!).
My case was as described above, git had messed up its references... Git log
was showing "your branch seems to be broken" and git fsck
was giving me warnings about bad references. Figured if I can probably fix it but I'd spend a lot of time doing it, so I went for the ugly workaround.
The index file has become corrupted, but it is easily re-creatable. Just remove it...
rm .git/index
Then you can re-add the files you're trying to stage.
If you want to keep local changes, use the following:
$ rm .git/index
$ git reset HEAD .
> Unstaged changes after reset:
modified foo.txt
modified bar.txt