I know how to delete a tag from SourceTree. Just right-click, delete, and tick "remove tag from all remotes." It then executes the following (and I'm omitting the flags -c diff.mnemonicprefix=false -c core.quotepath=false
for readability):
git tag -d my_tag
git push -v origin :refs/tags/my_tag
This works.
Here is the problem.
Some time later, one of the other developers will push their feature branch to origin, and SourceTree will automatically push all local tags to the remote server. This will recreate the tag I just deleted.
I know the idea is that tags are not "supposed" to be deleted, e.g. tagged releases, but sometimes mistakes happen.
Any advice?
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 get a list of Git tag names, run git tag.
Click on the tag in the example page or email. From the pop-up menu that displays after you click the tag, select Clear tag.
You can't remove a tag from Bitbucket after you've added it.
The only solution I have found is to simply ask all the other developers to remove their local copies of the tags after you have deleted them from the remote. I found a script help here.
To put it simple, if you are trying to do something like git fetch -p -t, it will not work starting with git version 1.9.4.
However, there is a simple workaround that still works in latest versions:
git tag -l | xargs git tag -d # remove all local tags git fetch -t # fetch remote tags
A one liner can be written as:
git tag -l | xargs git tag -d && git fetch -t
Alternative, you can add a new alias to your ~/.gitconfig file to make things shorter:
in ~/.gitconfig
[alias] pt = !git tag -l | xargs git tag -d && git fetch -t
Now, you can simply call pt alias to prune local stale tags:
git pt
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