git - How to delete a remote tag?

ID : 90

viewed : 453

Tags : gitgit-taggit

Top 5 Answer for git - How to delete a remote tag?

vote vote


You can push an 'empty' reference to the remote tag name:

git push origin :tagname 

Or, more expressively, use the --delete option (or -d if your git version is older than 1.8.0):

git push --delete origin tagname 

Note that git has tag namespace and branch namespace so you may use the same name for a branch and for a tag. If you want to make sure that you cannot accidentally remove the branch instead of the tag, you can specify full ref which will never delete a branch:

git push origin :refs/tags/tagname 

If you also need to delete the local tag, use:

git tag --delete tagname 


Pushing a branch, tag, or other ref to a remote repository involves specifying "which repo, what source, what destination?"

git push remote-repo source-ref:destination-ref 

A real world example where you push your master branch to the origin's master branch is:

git push origin refs/heads/master:refs/heads/master 

Which because of default paths, can be shortened to:

git push origin master:master 

Tags work the same way:

git push origin refs/tags/release-1.0:refs/tags/release-1.0 

Which can also be shortened to:

git push origin release-1.0:release-1.0 

By omitting the source ref (the part before the colon), you push 'nothing' to the destination, deleting the ref on the remote end.

vote vote


A more straightforward way is

git push --delete origin YOUR_TAG_NAME 

IMO prefixing colon syntax is a little bit odd in this situation

vote vote


If you have a remote tag v0.1.0 to delete, and your remote is origin, then simply:

git push origin :refs/tags/v0.1.0 

If you also need to delete the tag locally:

git tag -d v0.1.0 

See Adam Franco's answer for an explanation of Git's unusual : syntax for deletion.

vote vote


Delete all local tags and get the list of remote tags:

git tag -l | xargs git tag -d git fetch 

Remove all remote tags

git tag -l | xargs -n 1 git push --delete origin 

Clean up local tags

git tag -l | xargs git tag -d 
vote vote


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

The first line deletes your_tag_name from local repo and second line deletes your_tag_name from remote repo.

For those who use GitHub, one more step is needed: discarding draft. enter image description here

Top 3 video Explaining git - How to delete a remote tag?