git tag -l does not remove deleted tags

2.7k Views Asked by At

This is the scenario

I cloned my repository to a directory which I regularly update by

git pull

Now I created one more directory and checked out same repository

I had to create some tags, but by mistake I created tags with wrong name so I deleted tags from the first directory

git tag -d old
git push origin :refs/tags/old
git push --tags

If from second directory I am trying

git tag -l

I am not able to get synchronised information as tag does not get deleted from list

Then I did

git pull --tags

Added tags get reflected but deleted tags does not get deleted.

git pull origin --tags

No change to result

How can I get synchronised list so that tags deleted are also reflected in other directory.

1

There are 1 best solutions below

1
On BEST ANSWER

The following will delete any local tags that are not on the remote.

git fetch origin refs/tags/*:refs/tags/* --prune

In order to fetch tags automatically, add the following line to your .git/config file under the entry for [remote "origin"].

fetch = refs/tags/*:refs/tags/*