Reputation: 2638
How do I list the tag name, tag date and tag message for all tags?
It seems that git's separation of display logic for commits through git log
and tags through git tag
makes it difficult to list the tag name, the tag's date and the tag message.
I can show the tag date, name and commit message using git log --tags --show-notes --simplify-by-decoration --pretty="format:%ai %d %s"
I inspected http://opensource.apple.com/source/Git/Git-26/src/git-htmldocs/pretty-formats.txt but didn't see any option to show tag message.
I can show the tag name and 5 lines of tag message using git tag -n5
.
But to get all three pieces of info would appear to require gnarly scripting beyond my ability.
Upvotes: 39
Views: 33316
Reputation: 18455
How about a bit nicer colorful format?
# ~/.gitconfig
[alias]
tags="for-each-ref --sort=taggerdate --format='%(color:green)%(subject)%(color:reset), tagged: %(refname:short)\n%(taggerdate)\n%(taggername) %(taggeremail)\n\n%(contents:body)\n' refs/tags"
$ git tags
Release 1.0.1, tagged: 1.0.1
Wed Jul 4 20:16:05 2018 +0430
Sepehr Lajevardi <sepehr.lajevardi@...>
Changelog
- Implement Contentful webhooks to purge internal and CF caches.
- Implement CloudFlareService.
- Fix Contentful's mapping concern usage/namespace. #73
- Temporarily enforce https in og:url property. #103
- Fix entry callback issue with Contentful client. #99
- Fix issue with PPM docker build. #96
Release 1.1.2, tagged: 1.1.2
Thu Jul 12 21:26:29 2018 +0430
Sepehr Lajevardi <sepehr.lajevardi@...>
Changelog
- Fix GA share event issue with AddThis. #132
- Optimize OpenGraph protocol tags for articles. #130
- Optimize Twitter card tags. #131
- Fix HTML validation errors as much as possible. #127
Release 1.1.3, tagged: 1.1.3
Mon Jul 16 22:49:05 2018 +0430
Sepehr Lajevardi <sepehr.lajevardi@...>
Changelog
- Implement cross-device/browser fav/home icons. #137, #138
- Minify HTML output of all pages. #139
- Check for lighthouse score in build pipeline. #30
- Drop AddThis in favor of in-house ShareBar. #116
- Minor article OG tag adjustments.
Upvotes: 3
Reputation: 107
git tag --format="%(refname:short) %(authordate) %(authorname) %(subject)"
Example output
0.4.0 Wed Nov 2 11:17:50 2016 -0400 Captain Obvious Release: 0.4.0
Format fields the same as for git-for-each-ref
.
Upvotes: 5
Reputation: 1851
Use the this terminal command in your repository
git show --tags --no-patch
You can control the format with the same --format=
name options (oneline, short, medium, full, custom) used with git log
.
git show --tags --no-patch --format=short
Upvotes: 4
Reputation: 141
If you want to fetch the latest tag details, use --sort
flag, remember that if you are sorting on dates, use '-' before the date to list the newest first.
For example, I wanted the latest tag description (as it happens to be the latest release name), I used --format to just pull the subject of the tag and sort it taggerdate wise (newest first). Here's the command for that.
git for-each-ref --sort=-taggerdate --format '%(subject)' refs/tags --count=1
Upvotes: 0
Reputation: 14843
You want to use the for-each-ref
command. Unfortunately, it's only slightly less user friendly than filter-branch
Note that information like tag date and the tagger is only available for annotated tags.
Below is a basic prototype. Note that the format= can be an entire shell script of its own, and probably should be depending on how complicated you want the output. They have a couple of examples specifically for tags in the for-each-ref documentation
git for-each-ref --format="%(refname:short) %(taggerdate) %(subject) %(body)" refs/tags
Upvotes: 30
Reputation: 5741
This is rather a follow up question to Andrew's response, slightly different but related topic.
git for-each-ref --format="%(refname:short) %(taggerdate) %(subject) %(body)" refs/tags
This works great on direct command line. When I set a git alias in ~/.gitconfig, it does not seem to spew the same output.
When invoked on command line directly, I get.
package-release-14.7.2 Wed Dec 3 14:24:38 2014 -0800 14.7.2: copy for tag package-release-14.7.2
package-release-14.7.3 Thu Dec 4 14:14:55 2014 -0800 14.7.3: copy for tag package-release-14.7.3
package-release-14.7.4 Fri Dec 5 16:16:40 2014 -0800 14.7.4: copy for tag package-release-14.7.4
And when I invoke a git alias(taghist = for-each-ref --format="%(refname:short) %(taggerdate) %(subject) %(body)" refs/tags), I get
package-release-14.7.2
package-release-14.7.3
package-release-14.7.4
-San
Upvotes: -2
Reputation: 2571
I don't know if there's a way to
list only the tag name, tag date and tag message for all tags using only the git syntax.
But a simple grep will do the job:
git show --tags |grep "^tag " -A4
Notice I specify 4 lines of trailing context after matching, because the standard output shows tag name, tag date and tag message each on a separate line.
If you need to deal with multiline tag messages I would prefer using piping to awk which is slightly more cumbersome:
git show --tags |awk "/^tag /,/-----BEGIN PGP SIGNATURE-----|commit /" |egrep -v "^$" |sed -E "s/^-----BEGIN PGP SIGNATURE-----.*|^commit.*/-/"
This will work as long as the tag message is followed by either the PGP SIGNATURE or the commit message, which afaik are all the possibile situations. However, you can easily adapt the last grep to cover other situations (if there were to be).
Upvotes: 1
Reputation: 44244
git show --tags
will at least output all the relevant information about your tags. You might be able to find an appropriate --pretty=format:
sequence from there.
Upvotes: 9