Search code examples
git

git pull error: cannot lock ref 'ref/remotes/origin/xxx' ... exists; cannot create


I have done several git pulls today, without issue.I have not changed or modified anything locally.

Now I do another git pull, and out of the blue get this:

error: cannot lock ref 'refs/remotes/origin/task/DEV-2527/DEV-2535': 'refs/remotes/origin/task/DEV-2527' exists; cannot create 'refs/remotes/origin/task/DEV-2527/DEV-2535'
From https://dev.azure.com/xxx/xxx-web/_git/xxx-web
 ! [new branch]          task/DEV-2527/DEV-2535 -> origin/task/DEV-2527/DEV-2535  (unable to update local ref)

I tried "git gc" but this didn't help.

I have read that "git remote prune origin" may help, but I don't want to do anything which could damage the azure remote repo.


Solution

  • git fetch --prune 
    

    Fixed it for me. A developer accidentally created a new branch with a path of an old branch. The old branch was later deleted on the origin, so presumably prune fixed this locally.

    Thanks to Krzysiek Karbowiak for the help.