Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git reference conflicts between branches (unable to update local branch)

Tags:

git

github

I'm experiencing the following error while trying to git fetch a remote branch:

error: Ref refs/origin/remotes/my-branch is at some-hash but expected another-hash From github.com:my-repository ! some-hash my-branch -> origin/my-branch (unable to update local ref)

I have no idea what the hell just blew up. Any enlightenment?

like image 280
Alan R. Soares Avatar asked Oct 23 '13 17:10

Alan R. Soares


People also ask

How do I fix broken references in git?

Solution. Unsure the root cause of the "reference broken". To fix it, delete this file . git/refs/remotes/origin/master , and git fetch to retrieve it back.

How to check conflicts in git branch?

You can see the different versions of same code in the two branches. You need to choose which version is the old one. If you want to see the differences in same div, you can run the following command: git diff –color-words master..

What does git fetch prune do?

git fetch --prune is the best utility for cleaning outdated branches. It will connect to a shared remote repository remote and fetch all remote branch refs. It will then delete remote refs that are no longer in use on the remote repository.


2 Answers

I've found this error's cause:

Someone has created another branch with the same name, but different case.

What happened?

Git for windows isn't case sensitive. So, things just got crazy! Git couldn't distinguish one from another, mistaking the hash of each's head.

Solution:

Just cut the evil by its root. Wrong remote branch was deleted and evererything is nice as ever.

like image 162
Alan R. Soares Avatar answered Oct 18 '22 02:10

Alan R. Soares


For other googlers who get here: this is also another less drastic approach:

Navigate to .git\refs\remotes\origin directory - delete the master file,

Then do another git pull and it synchronizes successfully.

like image 23
JaredBroad Avatar answered Oct 18 '22 02:10

JaredBroad