Sitam Jana
Sitam Jana

Reputation: 3129

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

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.

Upvotes: 3

Views: 4167

Answers (1)

rjmunro
rjmunro

Reputation: 28096

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.

Upvotes: 6

Related Questions