17

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 ?

code_fodder
  • 15,263
  • 17
  • 90
  • 167
My real name
  • 535
  • 1
  • 5
  • 17

1 Answers1

42

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):

  1. 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

  2. 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.

dcharles
  • 4,822
  • 2
  • 32
  • 29
code_fodder
  • 15,263
  • 17
  • 90
  • 167