Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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.

like image 896
kayaker243 Avatar asked Aug 31 '12 16:08

kayaker243


People also ask

How do I fetch all tags?

To fetch tags from your remote repository, use “git fetch” with the “–all” and the “–tags” options. Let's say for example that you have a tag named “v1. 0” that you want to check out in a branch named “release”. Using this command, you have successfully checked out the “v1.

What is git tag message?

Tags are ref's that point to specific points in Git history. Tagging is generally used to capture a point in history that is used for a marked version release (i.e. v1. 0.1). A tag is like a branch that doesn't change. Unlike branches, tags, after being created, have no further history of commits.


2 Answers

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 
like image 74
Andrew C Avatar answered Sep 21 '22 18:09

Andrew C


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.

like image 35
Christopher Avatar answered Sep 23 '22 18:09

Christopher