index file smaller than expected

前端 未结 3 1042
滥情空心
滥情空心 2021-02-01 00:25

This morning, I started getting this error from git:

fatal: index file smaller than expected

fatal: git status --porcelain failed

3条回答
  •  执念已碎
    2021-02-01 00:54

    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!).

    1. Make backup of your files, what I am about to say should work but do it just in case.
    2. Remove the .git folder
    3. Clone your repository (does not matter where) I did it in the current directory
    4. Copy the created from the clone .git directory into your current directory
    5. Remove the cloned directory 6. Optional, if you used a branch checkout to it again
    6. Git status should now track changes as it is supposed to and all your git commands should work

    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.

提交回复
热议问题