This is the error message :
error: cannot lock ref 'refs/remotes/origin/master': unable to resolve reference 'refs/remotes/origin/master': reference broken
From https://bitbucket.org/abc/abc
! [new branch] master -> origin/master (unable to update local ref)
when I try to pull then it shows "Complete with errors, see above", I forgot what I did before so it result this error came up after I do pull request. What should I do ?
The detailed error was: git pull error: cannot lock refs, cannot lock ref refs is at but expected, how to fix? This will do is remove references to remote branches in the folder .git/refs/remotes/origin.
Since we use Github I could solve the problem by deleting one of the branches via Github's GUI. This error with (unable to update local ref) can also happen if you have changed passwords recently and there's some fancy stuff integrating your Windows and Linux logins.
The local references to your remote branches were changed and hence when you run git pull, git doesn't find any corresponding remote branches and hence it fails. actually cleans this local references and then run git pull again. Now it keeps on running prune automatically. Clone the repository again, and copy the .git folder in your broken project.
This error with (unable to update local ref) can also happen if you have changed passwords recently and there's some fancy stuff integrating your Windows and Linux logins. Show activity on this post. Clone the repository again, and copy the .git folder in your broken project.
It sounds like your ref to the origin/master branch is broken or corrupt.
First - take a copy of your local repo.
You can do two things (that I know of):
Delete the ref to master and then do a fetch (to get the latest):
cd <path-to-your-repo>
rm .git/refs/remotes/origin/master
git fetch
Try using the git maintenance features:
git gc --prune=now
git remote prune origin
(may not need this which removes stale remote tracking branches and such)Note: One reason to backup before you do this is that the git gc pruning permanently removes some commits that are un-reachable - which, in theory, you might need incase you made a mistake.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With