I have deleted some tags by running:
git tag -d TAGNAME
git push origin :refs/tags/TAGNAME
After that I asked all team members to run:
git tag -d $(git tag)
- to remove all local tagsgit 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?
Use Git to delete a Git tag To delete the Git tag from the local repo, run the git tag -d tag-name command where tag-name is the name of the Git tag you want to delete.
To fetch tags from your remote repository, use “git fetch” with the “–all” and the “–tags” options. Let's say for example that you have a tag named “v1. 0” that you want to check out in a branch named “release”. Using this command, you have successfully checked out the “v1.
You do not remove commits. You remove pointers to commits and if commits are no longer referenced git will garbage collect them some day (depending on your configuration).
Delete a local Git tag If you try to delete a Git tag that does not exist, you will simply be notified that the tag does not exist. $ git tag -d v2. 0 error: tag 'v2. 0' not found.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With