Corrupted .git/index File: “git fatal: unordered stage entries in index”
This is a post for geeks like me using the git source code repository.
UDPATE 2021-10-11: all this trouble was really the result of bad memory in the server.
...
Today my web server somehow corrupted its .git/index file, rendering it impossible to pull any updates:
git fatal: unordered stage entries in index
I think I might have hit control-C at the wong time, and git corrupted the index file.
Because the repo is ~364GB, it is not an option to just pull it again! Yes, I know I am abusing git for a massive website—it was never designed for a repo that will soon approach half a terabyte. But as a testament to how well written it is, it has worked great.
I was shitting bricks that this meant a 300 mile drive home, then a visit to the Tier 1 server room in order to manually copy over a fresh/good git repo.
As it turns out, this simple approach worked just fine to rebuild .git/index:
rm .git/index
git reset
After 30 minutes or so, the job was done; git has to read the entire set of pack files totaling ~364GB, so it took a while even on an SSD.