14

I am a newcomer to git and was quite happy until this evening. I have been committing changes regularly. I maintain two remotes on unfuddle and beanstalk and a local filesystem remote.

Never had an error and after a days work, I push my changes up to all the remotes believing that woud keep me pretty safe. There were no errors and no problems.

This evening, I went to look over the log of my project and got this error for my pains:

error: Could not read a2b6c2fa16e01db9e38d9509606a444e5831330a
fatal: Failed to traverse parents of commit 
       78e81a9a7f5cafa5e2af4b95d156364b9a430ac9

As far as I can see the history is good as far back as May 29th. I cannot clone a copy from any of the remotes. There are no other clones anywhere that I could use to recover the repository. I don't even really know when it broke. I checked the FAQ but I have no idea what the author of the repository recovery section is talking about.

WhenI run git fsck, I get 155 lines of missing this and dangling that. Clearly, I would like to get this cleaned up. I can live with no history prior to May 29th If I could get it straight from then onwards.

Can anyone help me get this straight?

Also, what could cause this? The only thing I can think of that has changed in that period is that I upgraded netbeans to v7 which is supposed to have git support but seems not to recognise existing repositories.

New Alexandria
  • 6,951
  • 4
  • 57
  • 77
Peter Harrison
  • 367
  • 1
  • 3
  • 15

2 Answers2

17

I googled this error and found your page, in my case the problem was that I had done:

git clone --depth 1 https://github.com/example/nifty.git

but months later, forgetting that I had only grabbed the latest commits, when I tried to push it to another remote it complained. It took me a little while to figure out that it wasn't a damaged repo but just the fact that I never had the parent commits! Hopefully that helps someone.

This fixed it for my case:

git fetch --unshallow
weston
  • 1,972
  • 17
  • 17
  • 8
    What did you do to fix it in this case? – Zahymaka Aug 20 '12 at 03:33
  • Lol, I edited my answer to show the solution in my case. – weston Apr 26 '14 at 00:44
  • 11
    I've found I get `fatal: --unshallow on a complete repository does not make sense`. This might be a bug with git, but re-running `git fetch --depth=1` before the `--unshallow` seems make git actually unshallow. – jozxyqk Oct 17 '17 at 23:20
2

"Dangling" objects may not be a problem. It could just mean that you've done some resetting, rebasing, and/or deleted branches that weren't fully merged. "Missing", on the other hand, is more serious, I believe. Take a look at this article on repairing a damaged repo. That might help you out. You could also try upgrading git if you're out of date. A newer version might be a little smarter.

Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199
  • Thank you. However, as with @Andy's answer, you point to the same article that I failed to understand. My circumstance is different. The error is several weeks back and the object that fails to read is not damaged, it is not there. the trail seems to stop cold. – Peter Harrison Jul 17 '11 at 08:04