Reputation: 456
fatal: Duplicated ref, and SHA1s don't match: refs/heads/BranchName
I should note that I'm on Ubuntu Lucid, which is relevant for some of the file system comments.
I got this error right after doing a git pull origin master while locally on master. Pretty usual thing to do. The pull itself seemed to work, I saw the list of all the files being pulled down. But nothing after that has.
I looked at some of the other answers on SO, but they all involve running a git command. At this point I can't run any git command, fsck included. I just get the same message. I was suggested that I delete .git/refs/heads/BranchName but it didn't work. Though I saw an interesting thing: The only thing in /refs/heads was the bad branch, with a ? at the end (probably some unknown character). No other branches listed there.
I've had issues in the past where git fsck would fail, and then it magically was ok again. Sounds a lot like HD failure, but smartctl's long test told me nothing bad when that happened before. I tried the quick status check just now and it seems to be fine still.
Not a huge deal, I can re-clone. I didn't lose much. But it would be nice to get it back, and also to have this here for others who get the same problem.
Thanks.
Upvotes: 2
Views: 743
Reputation: 12946
I managed to reproduce the problem: the file .git/packed-refs
has two entries for refs/heads/BranchName
and they have different SHAs, git doen't know which one is the correct and leaves your with that fatal error.
Delete one of them to resolve the conflict, your BranchName
branch may end up pointing to a nonexistent commit, but you'll be able to run git commands again.
Upvotes: 3