Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 views
in Technique[技术] by (71.8m points)

git - 如何删除远程标签?(How to delete a remote tag?)

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

  ask by markdorison translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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):

(或者,更--delete ,使用--delete选项(如果您的git版本早于1.8.0,则使用-d ):)

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.

(请注意,git具有标记命名空间和分支命名空间,因此您可以对分支和标记使用相同的名称。)

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

Background (背景)

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.

(通过省略源ref(冒号前的部分),将'nothing'推送到目标,删除远端的ref。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...