Git: remote: fatal: index file corrupt, "index uses yz extension"?

Viewed 351

I have just encountered an issue I have never seen before and can't find any help on.

I run a git master repo on the live website in our hosting environment, and a bare origin repo on the same server. All our developer commits go to the bare origin master, which has a post-receive hook to push each commit to the master repo so that the push is reflected in the live site files. The only annoyance is that whenever we get WordPress updates, we have to commit on the master repo, then push it back to the origin repo so that our developers can download those updated files.

Problem: Today, I went to commit a WordPress plugin update, and the commit worked fine, but the push gave the following cryptic error that I cannot find any help on:

git push origin master

Counting objects: 344, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (323/323), done.
Writing objects: 100% (344/344), 1.76 MiB | 5.61 MiB/s, done.
Total 344 (delta 237), reused 14 (delta 1)
remote: Resolving deltas: 100% (237/237), completed with 226 local objects.
remote: Running post-receive (git pull origin master):
remote: error: index uses ▒yz▒ extension, which we do not understand
remote: fatal: index file corrupt

(The weird symbols around the letters "yz" reads as "<B3>yz<AC>" when I run git diff)

If I run git status on master (cannot be run on origin as it is a bare repo), it repeats the last two lines of output. If I run git log on both repos, they look normal, but the origin is of course one commit behind the master, because committing to master worked, but pushing to origin failed.

I have never heard of this "yz" extension before, and as far as I can tell, no one else has either. All I did was a commit and a push and the push failed. We do not use any such "yz" extension, we use vanilla Git, do very basic pushes and pulls, our post-receive hook is about a 5 line script which just auto-pushes every commit from origin to master and resets file permissions to ensure they're readable by the web server. The only weird thing we're doing is using Git to manage a WordPress site for version control. All developers use TortoiseGit on Windows without any special settings or any sort of plugins.

I have seen plenty of questions and answers about corrupt indexes, but nothing like this.

I have not tried anything yet as I'm not sure what to do, don't understand the internals of Git, and don't want to break anything, but we need to be able to pull and push and cannot until the repos are in sync again.

2 Answers

Alright, here's what I did:

Because I did not want to lose any changes to the master repo (corrupt index), as the changes needed to be kept and also pushed to origin (working index), I ran the following:

rm .git/index
git reset --mixed

(mixed is the default option)

According to the documentation:

--mixed
Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.

Thanks to torek and bk2204 for your help in understanding the situation, and a little bit of googling to figure out the safest process for resetting an index without losing any committed or working files

Everything prefixed with remote: came not from your Git but from their Git—the Git your Git called up, at the URL you used when you ran git push.

It's their Git that is complaining about their Git's index. This is probably a file corruption issue on their machine. You need to get them—whoever "they" are—to check out their system. If all looks OK, they should probably just remove and rebuild their index files.

(If "they" / "them" is really you, go over to whichever machine(s) are involved, inspect them carefully for damage or disks that are on fire or whatever, and if all looks good, remove and rebuild the index files.)

Related