Main Tutorials

Git – Unable to resolve reference ‘refs/remotes/origin/master’: reference broken

A git pull and hits the below "reference broken" error message?

Terminal

$ git pull

error: cannot lock ref 'refs/remotes/origin/master':
    unable to resolve reference 'refs/remotes/origin/master': reference broken

From bitbucket.org:xx/mkyong-tutorials
 ! [new branch]      master     -> origin/master  (unable to update local ref)  

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.

Terminal

$ rm .git/refs/remotes/origin/master

$ git fetch

 From bitbucket.org:xx/mkyong-tutorials
    df0eee8..3f7af90  master     -> origin/master

$ git pull
 Already up to date.

References

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
5 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Abdullah Farouk
2 years ago

> git fetch
error: cannot lock ref ‘refs/remotes/origin/develop’: unable to resolve reference ‘refs/remotes/origin/develop’: reference broken
From https://bitbucket.org/my-repo
 ! [new branch]     develop  -> origin/develop (unable to update local ref)

> git pull
error: cannot lock ref ‘refs/remotes/origin/develop’: unable to resolve reference ‘refs/remotes/origin/develop’: reference broken
From https://bitbucket.org/my-repo
 ! [new branch]     develop  -> origin/develop (unable to update local ref)

Yinka
1 year ago

I just want to say thank you!!!

Paul Fruitful
1 year ago

Thanks for sharing this it worked for me

Alex
2 years ago

doesn’t work to me!
rm: cannot remove ‘.git/refs/remotes/origin/master’: Not a directory

Paul Fruitful
1 year ago
Reply to  Alex

Uhmm…
Check your remote name and replace the /origin with it 🙂