7 Answers
7

Note, this won't differentiate between lightweight and annotated tags. For lightweight tags it'll show the commit and for annotated tags it'll show the hash of the tag object itself.
–
Kevin BallardJan 9 '12 at 23:43

7

To show a list of tags with dereferenced refs (in case of annotated tags) use git show-ref --tags -d. Dereferenced tags are postfixed with a ^{}.
–
S. Christoffer EliesenNov 10 '12 at 19:30

To get the SHA1 referred to by any sort of ref (branch, tag...) use git rev-parse:

git rev-parse tag1^0 tag2^0

It will print only the full SHA1s, on separate lines. The ^0 suffix is a special syntax, to ensure that this will print the SHA1 of the commit pointed to by the tag, whether it's annotated or not. (Annotated tags are objects in their own right, which contain a pointer to a commit along with metadata. If you do know a tag is annotated, and want the tag's SHA1, simply leave off the ^0.)

Of course, you shouldn't often need to do this, since any Git command that would accept an SHA1 should also accept a tag!

The git tag command is underdeveloped. A lot is desired but missing in it, like full tag details and tags in the commit history order.

I like this instead, which gives exactly what I want but can't get from git tag:

git log --oneline --decorate --tags --no-walk

This gives a very nice color-coded view of the tags in the reverse chronological order (as it would be in the full log). That way, not only do you see the tags, you will also see the abbreviated hashes and the commit messages of the tag commits.