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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With