Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git tag another tag

Tags:

git

git-tag

How can I put a tag on same references of another tag? For example I would like to put tag "Stable_Build" on a tag of a certain release "1.0.0.1".

Is there a better\faster way to do it except to:

git checkout 1.0.0.1
git tag -a Stable_Build
like image 693
OkyDokyman Avatar asked Dec 17 '25 18:12

OkyDokyman


2 Answers

git tag new_tag old_tag is problematic if the old tag is annotated, as torek commented.

This was illustrated on the Git mailing list by Robert Dailey.

And this is why Git 2.22 (Q2 2019) will warn you, giving an advice suggesting it might be a mistake when creating an annotated or signed tag that points at another tag.

See commit eea9c1e, commit 01dc801 (04 Apr 2019) by Denton Liu (Denton-L).
Helped-by: Jeff King (peff), and Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano -- gitster -- in commit a198562, 08 May 2019)

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.

You will now see, when tagging a tag (nested tagging):

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^{}

So, if you already did:

git tag stable 1.0.0

You can fix it with:

git tag -f stable 1.0.0^{}

There might be later a "git tag --allow-nested-tag -f stable 1.0.0" (if you actually wanted to tag the tag 1.0.0 by another annotated tag), but this is not implemented yet.

like image 156
VonC Avatar answered Dec 20 '25 13:12

VonC


go with git tag <new_tag> <old_tag> (see docs)

$ git tag stable 1.0.0

$ git tag --list
1.0.0
stable

By the way: it would not refer to tag 1.0.0 but to same commit as tag 1.0.0.

like image 33
dfens Avatar answered Dec 20 '25 12:12

dfens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!