Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git fetch --tags showing error: cannot lock ref 'refs/remotes/origin/pr/

Tags:

git

I am trying to execute following git command -

git fetch --tags --progress https://github.com/<org>/<repo-name>.git +refs/pull/*:refs/remotes/origin/pr/*

and constantly getting errors:

error: cannot lock ref 'refs/remotes/origin/pr/1/head': 'refs/remotes/origin/pr' exists; cannot create 'refs/remotes/origin/pr/1/head'
From https://github.com/<org>/<repo-name>
 ! [new ref]             refs/pull/1/head    -> origin/pr/1/head  (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/pr/10/head': 'refs/remotes/origin/pr' exists; cannot create 'refs/remotes/origin/pr/10/head'
 ! [new ref]             refs/pull/10/head   -> origin/pr/10/head  (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/pr/100/head': 'refs/remotes/origin/pr' exists; cannot create 'refs/remotes/origin/pr/100/head'
 ! [new ref]             refs/pull/100/head  -> origin/pr/100/head  (unable to update local ref)

Any hints regarding how to solve would be really appreciated.

like image 289
Sitam Jana Avatar asked Jun 28 '26 15:06

Sitam Jana


1 Answers

It looks like there used to be a branch called pr, and the new branch is in a folder with that name, so it is clashing.

Try git remote prune origin, which should remove the local tracked copy of the old branch, then your command again.

like image 67
rjmunro Avatar answered Jul 01 '26 05:07

rjmunro