Git 标记另一个标记

Git tag another tag

如何将一个标签放在另一个标签的相同引用上? 例如,我想将标签 "Stable_Build" 放在某个版本“1.0.0.1”的标签上。

有没有 better\faster 的方法,除了:

git checkout 1.0.0.1
git tag -a Stable_Build

选择 git tag <new_tag> <old_tag>(参见 docs

$ git tag stable 1.0.0

$ git tag --list
1.0.0
stable

顺便说一句:它不会引用标签 1.0.0,而是引用与标签 1.0.0 相同的提交。

git tag new_tag old_tag 如果对旧标记进行注释,则会出现问题,如 torek .

这是罗伯特·戴利 illustrated on the Git mailing list 的作品。

这就是为什么 Git 2.22(2019 年第 2 季度)会警告您,给出建议,建议在创建指向另一个标签的带注释或签名的标签时可能是错误的。

参见 commit eea9c1e, commit 01dc801 (04 Apr 2019) by Denton Liu (Denton-L)
Helped-by: Jeff King (peff), and Ævar Arnfjörð Bjarmason (avar).
(由 Junio C Hamano -- gitster -- in commit a198562 合并,2019 年 5 月 8 日)

tag: advise on nested tags

Robert Dailey reported confusion on the mailing list about a nested tag which was most likely created by mistake.
Jeff King noted that this isn't a very common case and creating a tag-to-a-tag can be a user-error.

Suggest that it may be a mistake with an advice message when creating such a tag.
Those who do want to create a tag that point at another tag regularly can turn it off with the usual advice mechanism.

您现在将在标记标签(嵌套标记)时看到:

hint: You have created a nested tag. The object referred to by your new is
hint: already a tag. If you meant to tag the object that it points to, use:
hint: |
hint: git tag -f nested annotated-v4.0^{}

那么,如果您已经这样做了:

git tag stable 1.0.0

您可以通过以下方法修复它:

git tag -f stable 1.0.0^{}

稍后可能会有一个“git tag --allow-nested-tag -f stable 1.0.0”(如果您实际上想要通过另一个带注释的标签来标记标签1.0.0),但这是not implemented yet.