Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

I'm using git to manage files on a project, and keep running into this problem.

When I run git status I get the message

fatal: unable to read tree e2d920161d41631066945a3cbcd1b043de919570

As I understand it, I should check the output of git fsck, and I receive

broken link from    tree e09a42f248afff64336fbbec2523df97c26451ac
              to    tree e2d920161d41631066945a3cbcd1b043de919570
broken link from    tree e09a42f248afff64336fbbec2523df97c26451ac
              to    tree 9b0dd389bd7f9e8d257395d57e0881b7957f9698
broken link from    tree e09a42f248afff64336fbbec2523df97c26451ac
              to    tree 9e288a4ad60d63f342dfd18237980674426aa725
broken link from    tree e09a42f248afff64336fbbec2523df97c26451ac
              to    tree 2a04647337089f554fab8c49cfd37149e5f4fc9f
broken link from    tree e09a42f248afff64336fbbec2523df97c26451ac
              to    tree ea16658b45ce961adc3c3f519b0e8d9672918ca8

together with a lot of missing blob messages.

Following various resources (e.g Git - Broken Links, Missing & Dangling Trees) I have simply re-cloned the project from github and started again.

Once I have re-cloned the project, all is good for a few commits, and then the problem arises again. Re-cloning every time doesn't seem to be optimal, and seems to go against the idea of using git, and I'd like to try and understand what is going on. How can I diagnose and fix this problem?

like image 616
cmhughes Avatar asked Jan 01 '14 16:01

cmhughes


2 Answers

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.

like image 105
VonC Avatar answered Oct 13 '22 18:10

VonC


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.

like image 8
Mark Leighton Fisher Avatar answered Oct 13 '22 19:10

Mark Leighton Fisher