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

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

5 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Abdullah Farouk
4 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
3 years ago

I just want to say thank you!!!

Paul Fruitful
3 years ago

Thanks for sharing this it worked for me

Alex
4 years ago

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

Paul Fruitful
3 years ago
Reply to  Alex

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