0

I am getting the following error when I try to fetch/pull any branch from the git repo.

error: cannot lock ref 'refs/tags/4.3.1.136/artifactory': 'refs/tags/4.3.1.136' exists; cannot create 'refs/tags/4.3.1.136/artifactory'
From https://dev.azure.com/myCompany/Tools/_git/sim
 ! [new tag]             4.3.1.136/artifactory -> 4.3.1.136/artifactory  (unable to update local ref)

I added another git repo credentials a few weeks ago but still everything was working fine (push/pull/fetch/merge/rebase). But today is the first time, I am getting this issue. Maybe the issue is related to the presence of other credentials. I have already edit the .gitconfig file and removed all traces of another credentials. I have already tried to run the following commands:

git gc --prune=now
git remote prune origin

I was able to fetch from the remote using git pull --no-tags but if I try to rebase the development branch to the main brach, I again get the above-mentioned error.

iBug
  • 35,554
  • 7
  • 89
  • 134
skm
  • 5,015
  • 8
  • 43
  • 104

1 Answers1

0

You have one tag with the name 4.3.1.136/artifactory and another with the name 4.3.1.136. Since Git refs are stored as directories and files, you cannot have a file (4.3.1.136) and a directory (4.3.1.136/ with file artifactory) at the same time.

Delete/rename one or both of them and fetch again from the remote.

knittl
  • 246,190
  • 53
  • 318
  • 364
  • I tried to delete the `4.3.1.136` and fetched again but Git always creates `4.3.1.136` first and then throws the same error that `cannot lock ref 'refs/tags/4.3.1.136/artifactory': 'refs/tags/4.3.1.136' exists; cannot create 'refs/tags/4.3.1.136/artifactory'` – skm Jan 03 '23 at 12:37
  • 1
    @skm then talk to the repository owner so that they remove one of the conflicting tags. This will never work satisfactory if you have conflicting tags. You can try to run `git pack-refs`, maybe this help, but I wouldn't recommend this as a solution. – knittl Jan 03 '23 at 12:39