Hi all, usually I list tags via the command git tag -l.
Is there any way to get separated list either just of annotated tags or just of lightweight tags?
Thanks in advance.
Antonio
Great question. I'm not sure you can get that granular using git alone. This is from the docs:
You can also search for tags that match a particular pattern. The Git source repo, for instance, contains more than 500 tags. If you’re interested only in looking at the 1.8.5 series, you can run this:
$ git tag -l "v1.8.5*"v1.8.5v1.8.5-rc0v1.8.5-rc1v1.8.5-rc2v1.8.5-rc3v1.8.5.1v1.8.5.2v1.8.5.3v1.8.5.4v1.8.5.5
Source: https://git-scm.com/book/en/v2/Git-Basics-Tagging
Hi Tyler, I already studied the official documentation. Indeed in official documentation is written
"Tag objects (created with -a, -s, or -u) are called "annotated" tags; they contain a creation date, the tagger name and e-mail, a tagging message, and an optional GnuPG signature. Whereas a "lightweight" tag is simply a name for an object (usually a commit object)."
-a
-s
-u
Well, I found that, both for an annotated tag and for a lightweight tag, git creats a file inside /ref/tags folder.
Further, git log command doesn't distinguish between an annotated tag and a lightweight tag.
So ... in which way can I understand the type (annotated or lightweight) of an already existing tag? This is again my original question.
Any further suggestion?
Kind Regards.
For annotated tags
You can see the tag data along with the commit that was tagged by using the git show command:
For lightweight tags
if you run git show on the tag, you don’t see the extra tag information. The command just shows the commit:
Your recent question:
in which way can I understand the type (annotated or lightweight) of an already existing tag?
Use `git show` and reference the output (differences noted above).
git show <existing-tag-name>
Your original question:
Again, I'm not sure this can be achieved with git commands but perhaps a custom script could be a solution.
Hi Tyler, I tried what you suggested: unfortunately git show <tag-name> is not useful because its output is the same for annotated and lighweight tags.
However using git tag -l -n is useful because it shows the related commit messages for lightweight tags, so I can compare the messages of all tags with the message of the related commit: assuming reasonably that annotated tags are used to enrich the commit and so they have a message different from the message of the commit, in this way I can deduce which are lightweight tags and which are annotated ones.
This is not the cleaned solution I was searching for, however thank you very much.
Regards.
It looks like you're new here. Sign in or register to get started.