I am getting this error in my git repository:
22:09:15 $ git status # On branch master error: Could not read 8124cc15c63be92d534e4cdfa33c38d54deee122 error: unable to read tree object HEAD nothing to commit (working directory clean)
A Google search for error: unable to read tree object HEAD
doesn't result in much help, this error seems to be very rare. I am not sure how to deal with it. Could it be a hard drive failure?
Edit: The output of git fsck
is the following:
broken link from commit 607328dc80e4901a55b95c683d4fbf43e6df28bf to tree 8124cc15c63be92d534e4cdfa33c38d54deee122 missing tree 8124cc15c63be92d534e4cdfa33c38d54deee122 dangling tree 56b5d4a5e429d251582ec927bca7ef1225510c41 dangling tree 0259d2d38b18b6136bb6070fb41faf3624453cc6
The Git “fatal: Could not read from remote repository” error occurs when there is an issue authenticating with a Git repository. This is common if you have incorrectly set up SSH authentication. To solve this error, make sure your SSH key is in your keychain and you connecting to a repository using the correct URL.
On a "broken link" message, you could follow the GitFaq recommendations:
- back up all your state so that anything you do is re-doable if you corrupt things more!
- explode any corrupt pack-files
- See "
man git-unpack-objects
", and in particular the "-r
" flag.
Also, please realize that it only unpacks objects that aren't already available, so you need to move the pack-file away from its normal location first (otherwisegit-unpack-objects
will find all objects that are in the pack-file in the pack-file itself, and not unpack anything at all)- replace any broken and/or missing objects
- This is the challenging part.
Sometimes (hopefully often!) you can find the missing objects in other copies of the repositories.
At other times, you may need to try to find the data some other way (for example, maybe your checked-out copy contains the file content that when hashed will be the missing object?).- make sure everything is happy with "
git fsck --full
"- repack everything to get back to an efficient state again
Notes:
Update July 2016 (7 years laters), with Git 2.10 soon to be released, you now have:
git fsck --name-objects
It helps naming the origin of those broken links
See "How to fix git error broken link from tree to tree?" for more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With