8

Someone made a commit on the wrong branch so I tried to move the commit to another branch. When I tried to roll back the commit, I got this error:

[user@server gitrepo]$ git reset --hard 9c2de3c0
fatal: unable to read tree 9c2de3c0af09fc07a84ff84b594beb5a6d489181

The object looks fine:

[user@server gitrepo]$ ls objects/9c/2de3c* -al
-r--r--r-- 1 git git 222 Aug 28 12:09 objects/9c/2de3c0af09fc07a84ff84b594beb5a6d489181

Why can't it read this object, and what do I do about that?

Edit: to distinguish my problem from others:

  • Git's database doesn't appear to be particularly out of sorts. Running git fsck -full shows only a few (~20) dangling blobs and one dangling commit. Which does not seem particularly alarming.
Community
  • 1
  • 1
doub1ejack
  • 10,627
  • 20
  • 66
  • 125
  • @Gabriele: I looked at that post, but that question, and it's answer, pertain to a `broken link from commit`. I have no such error when I run `git fsck`. – doub1ejack Aug 29 '13 at 16:54
  • 1) what does `git cat-file -t 9c2de3c0` show? 2) what does `git cat-file -p 9c2de3c0` show? (I suspect at least one will also fail, but it's worth a quick poke at it) – torek Aug 29 '13 at 18:54
  • @torek - 1) `git cat-file -t 9c2de3c0` = 'commit' 2) `git cat-file -p 9c2de3c0` = my message, 'MODULE: added similarterms (MM)' – doub1ejack Aug 29 '13 at 20:10
  • Hm, what about the "tree" and "parents" parts (in the `-p` output)? If you follow those IDs do they work? – torek Aug 29 '13 at 20:16
  • Did you follow https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F ? – VonC Aug 30 '13 at 11:35
  • @VonC: thanks, I've seen that section paraphrased elsewhere, but your link goes into enough depth that I stand a better chance of following it. It's going to be a couple weeks before I can get back to this & try it out though. – doub1ejack Aug 30 '13 at 16:28
  • See: http://stackoverflow.com/questions/801577/how-to-recover-git-objects-damaged-by-hard-disk-failure/22694491 – kenorb Mar 27 '14 at 17:35

1 Answers1

2

I've got the same problem. Solved it by checking and fixing disk. Some files were corrupted.

Mark Bowler
  • 104
  • 1
  • 3