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.
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.
My team and I ran into this error, unable to update local ref, when doing a pull in SourceTree.
Update 2020: Per @Edward Yang's answer below, @bryan's comment on this answer, and this question/answer you may need to run both
git gc --prune=now
andgit remote prune origin
. Running only the former has always worked for me but based on ppl's responses I think both are necessary to address different causes of the error.
We used:
git gc --prune=now
This removes any duplicate reference objects which should fix the issue.
Here are a few links where you can learn more about git references and pruning :
git tip of the week
git-prune documentation
git references
I solved as below:
git remote prune origin
with gitbach line commande, use git update-ref
to update reference of your local branch:
$ git update-ref -d refs/remotes/origin/[locked branch name]
then pull using $ git pull
[locked branch name]
is the name of the branch that the error is happening because of mismatch of commit Ids.
Try to use this command in your git repository root folder:
rm .git/logs/refs/remotes/origin/master
rm .git/refs/remotes/origin/master
It works to me!
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