'How to completely delete a remote git tag?

I deleted the tags in my local and remote by running the code below.

#!/bin/bash

tag_list=(`git tag -l`)

for tag in ${tag_list[@]};
    do
        echo "Delete tag: $tag"
        git tag -d $tag
        git push origin :refs/tags/$tag
    done

If a git tag is remotely deleted, but someone else merges it into the branch, the tag is revived. How can I completely delete a remote git tag?

git


Solution 1:[1]

You literally can't delete a remote tag at all. When you use git push --delete origin tag or git push origin :refs/tags/tag, you're not deleting a remote tag. You're asking a remote (another Git) to please delete its tag. It may or may not obey this request, depending on what permissions some provider has added (Git itself doesn't have this kind of permissions checking but does allow hosting providers to add it on, and most do).

Assuming the remote obeys your request, your problem now is reduced to figuring how to make that same remote Git stop obeying requests from others to create that tag. Again, you literally can't delete anyone else's tag, but if your hosting provider allows you to establish "who can create a tag" rules, you can have the hosting provider forbid others from creating that tag again. You'll have to ask them to delete their tags too, if you want them to do that.

Once you stop thinking about this in terms of making someone else do something, and in terms of asking them (politely, or perhaps less politely with git push --force) and whether or not you have enforcement mechanisms for obey/don't-obey rules on the remote, the problem gets a lot clearer.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 torek