List git tag names, dates and messages

kayaker243 picture kayaker243 · Aug 31, 2012 · Viewed 27.3k times · Source

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.

Answer

Andrew C picture Andrew C · Oct 25, 2014

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