How to diagnose and fix git fatal: unable to read tree

Following my older recommendation, it boils down to being able to find a repo which actually contains the missing elements (here full trees).
This is what is shown in "How to fix corrupted git repository?".

But if a full clone doesn't solve the problem, then it may be:

  • a corruption of the repo on the GitHub side (contact GitHub support to check).
  • some kind of corruption on the client side (your Ubuntu). Make sure to check if the issue persists with the latest Git release (1.8.5.2-1) from a custom PPA (Personal Package Archive).

Update July 2016, with Git 2.10 soon to be release, you now have:

git fsck --name-objects

See "How to fix git error broken link from tree to tree?" for more.


I would start with a fresh clone, then run git fsck on the unchanged, untouched clone. I'm wondering (as above) if your initial clone is corrupt, but in a way allowing you to perform a few operations before orphaning the trees.


This may or may not be the problem originally raised here, but note that you will see a "fatal: unable to read tree" error from git if the user account the git command is being run under is no longer able to read all files checked out from your repository due to an ownership/permissions issue.

So in many case the first thing to check should be that you've got ownership and permissions set correctly on the files in your working tree, as that may well fix the problem. :)


Something that just worked for me was stashing my changes, doing a git pull, and then popping the changes back off the stash stack. My corruption might of been pretty shallow, so it probably won't work for everyone but it's worth a try.

Here's the output I got when I stashed:

work@home ~/code/project $ git stash
fatal: unable to read tree 5fd5f4d0425b42e5b478773fa643dd6fd4918188
fatal: unable to read tree 5fd5f4d0425b42e5b478773fa643dd6fd4918188
Saved working directory and index state WIP on master: d93430c Generic commit msg.
HEAD is now at d93430c An older generic message.

After that I pulled and then popped and it cleaned itself up. Again, YMMV.

Tags:

Git