List git tag names, dates and messages

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.

  • git: Switch branch and ignore any changes without committing
  • Is there an GIT alternative for SVN Externals?
  • Push Xcode Project to TFS Git repository
  • Two different Git repo in same directory
  • How to fool git-svn to recognize merges made with svn?
  • Collaborate/Structure a large scale Phonegap project
  • 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.

  • cant configure dataSource and delegate
  • Run `git log` on a remote branch
  • Push to a non-bare Git repository
  • RuntimeError: Model class django_messages.models.Message doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
  • Git Bash is displaying strange characters on Windows 7
  • Submit patch to Github project without cloning repository to Github?
  • 4 Solutions collect form web for “List git tag names, dates and messages”

    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
    

    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.

    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).

    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

    Git Baby is a git and github fan, let's start git clone.