How to delete a git remote tag?

你如何删除已被推送的git标签?


You just need to 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

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

git tag --delete tagname

Background

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

git push where-to-push 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.


A more straightforward way is

git push --delete origin YOUR_TAG_NAME

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


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.

链接地址: http://www.djcxy.com/p/1362.html

上一篇: 将git分支合并到master中最好(也是最安全)的方法

下一篇: 如何删除一个git远程标签?