6

I have a git object that is corrupted. The size of the file is 0 in the git objects dir.

First a fsck:

git fsck --full fatal: loose object a35c1489005cca1ffeb3c2d3e4d63988408b6a24 (stored in .git/objects/a3/5c1489005cca1ffeb3c2d3e4d63988408b6a24) is corrupted 

Then a ls:

ls -l .git/objects/a3/5c1489005cca1ffeb3c2d3e4d63988408b6a24 ----------+ 1 sampath ???????? 0 Sep 13 15:26 .git/objects/a3/5c1489005cca1ffeb3c2d3e4d63988408b6a24 

That file doesn't exist on the disk!?

# git cat-file -t a35c1489005cca1ffeb3c2d3e4d63988408b6a24 error: unable to find a35c1489005cca1ffeb3c2d3e4d63988408b6a24 fatal: git cat-file a35c1489005cca1ffeb3c2d3e4d63988408b6a24: bad file 

I saw this error first when I tried to do a pull.
I tried removing the file and doing a pull, but that did not work. It complained that the file is missing.

When I removed the file and ran fsck, it showed me a lot of dangling objects

# git fsck --full broken link from commit 1e5980c224ff19b19ad99dbefed4c7c64c58aee6 to tree a35c1489005cca1ffeb3c2d3e4d63988408b6a24 dangling tree 0401d636a512b208dffd6ac6e153ab0a061f8d5d dangling blob 58014c0266784a1e3cc1502de82837c5f36c8514 dangling tree 0507fa56260c693cea678eab0343240c5bba06ad dangling tree 130770880c664a0b0cf5a21d037cbdba7480dc90 

I tired going back a few commits and it did not help.
Any pointers on how to recover from this?

4
  • 1
    Do you have a copy of the repo somewhere? If you do, snag the object from there. Since you were pulling it from somewhere, hopefully you have that object in that repo Commented Oct 4, 2011 at 15:15
  • Would stackoverflow.com/questions/801577/… help? (if you have backups of that repo, of course) Commented Oct 4, 2011 at 15:19
  • I tried this. I cloned the repository and unpacked the objects. But I could not find the loose object file that had 0 size. Does this mean that it belongs to one of my local commits that have not been pushed to remote as yet? Commented Oct 5, 2011 at 9:55
  • possible duplicate of Git: "Corrupt loose object" Commented Sep 3, 2013 at 7:26

1 Answer 1

1

Looks like a tree is corrupted. If you know your structure around those commits, you could guess what it is. Hopefully you can deduce what files were added or removed. Your blobs and other trees will be dangling as well. If you really want to recover from this and have no other clones of the repo, it's still possible but will involve some time and effort and luck.

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.