Ariel Einfeld
Ariel Einfeld

Reputation: 157

Git tags are showing even though I deleted them

I have deleted some tags by running:

  1. git tag -d TAGNAME
  2. git push origin :refs/tags/TAGNAME

After that I asked all team members to run:

  1. git tag -d $(git tag) - to remove all local tags
  2. git fetch --tags - to retrieve current tags from remote.

The problem is that now and then I see the old tags appearing again. I suspect that someone still has a few old tags and didn't delete them or pulled before I deleted or so.

Is there a way to completely delete a tag?

For example - to make a commit that deletes old tags and so before users will be able to push they will have to pull that commit and so it will change their tags. Is that possible?

Upvotes: 14

Views: 3220

Answers (2)

nicensee
nicensee

Reputation: 101

The solution from @eckes did not work for me; what did work was this answer from Joseph K Strauss:

https://stackoverflow.com/a/30782368/15382340

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

Upvotes: 8

eckes
eckes

Reputation: 67137

When you delete remote branches, you have to git remote prune origin in order to completely remove these deleted branches from the working copy.

Since tags are quite much the same as branches, I assume you need to prune here too.

git fetch also knows the --prune parameter, so either

git remote prune origin

or

git fetch --prune

should do the trick.

This is an additional safety measure: fetch only updates known remote branches and introduces new ones but never deletes them unless --prune is requested.

Upvotes: 8

Related Questions