git repository failed to traverse parent error

2020-07-06 08:19发布

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.

标签: git
2条回答
放我归山
2楼-- · 2020-07-06 08:36

"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.

查看更多
戒情不戒烟
3楼-- · 2020-07-06 08:47

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
查看更多
登录 后发表回答