John Little
John Little

Reputation: 12445

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.

Upvotes: 11

Views: 30739

Answers (3)

Ratko Amanovic
Ratko Amanovic

Reputation: 1

Try deleting packed-refs file in .git folder

Upvotes: -1

John Little
John Little

Reputation: 12445

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.

Upvotes: 29

Kaumadie Kariyawasam
Kaumadie Kariyawasam

Reputation: 1476

I faced the same issue like this and I removed folder, '.git/refs/remotes/origin' after removed, issue is solved to me

Upvotes: 10

Related Questions