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

Time:06-11

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.

CodePudding user response:

As a datapoint, if you git clone this repository to a new directory do you still see the same error? This will help us understand if this problem is indeed just local and/or remote. If you can clone to a different directory I would just use the new directory.

CodePudding user response:

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.

  •  Tags:  
  • git
  • Related