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.5
v1.8.5-rc0
v1.8.5-rc1
v1.8.5-rc2
v1.8.5-rc3
v1.8.5.1
v1.8.5.2
v1.8.5.3
v1.8.5.4
v1.8.5.5
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)."
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.
Antonio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
Is there any way to get separated list either just of annotated tags or just of lightweight tags?
Again, I'm not sure this can be achieved with git commands but perhaps a custom script could be a solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Antonio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tyler, I found an interesting, easy and quick workaround: it's confortable to use git cat-file -p for each tag, so the difference between an annotated tag and a lightweight one is glaring. :-)
Bye.
Antonio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.