Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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.

like image 839
John Little Avatar asked Feb 01 '26 18:02

John Little


2 Answers

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.

like image 164
John Little Avatar answered Feb 03 '26 08:02

John Little


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

like image 31
Kaumadie Kariyawasam Avatar answered Feb 03 '26 07:02

Kaumadie Kariyawasam