I want git to list all tags along with the full annotation or commit message. Something like this is close:
git tag -n5
This does exactly w
git tag -n99
Short and sweet. This will list up to 99 lines from each tag annotation/commit message. Here is a link to the official documentation for git tag.
I now think the limitation of only showing up to 99 lines per tag is actually a good thing as most of the time, if there were really more than 99 lines for a single tag, you wouldn't really want to see all the rest of the lines would you? If you did want to see more than 99 lines per tag, you could always increase this to a larger number.
I mean, I guess there could be a specific situation or reason to want to see massive tag messages, but at what point do you not want to see the whole message? When it has more than 999 lines? 10,000? 1,000,000? My point is, it typically makes sense to have a cap on how many lines you would see, and this number allows you to set that.
Since I am making an argument for what you generally want to see when looking at your tags, it probably makes sense to set something like this as an alias (from Iulian Onofrei's comment below):
git config --global alias.tags 'tag -n99'
I mean, you don't really want to have to type in git tag -n99
every time you just want to see your tags do you? Once that alias is configured, whenever you want to see your tags, you would just type git tags
into your terminal. Personally, I prefer to take things a step further than this and create even more abbreviated bash aliases for all my commonly used commands. For that purpose, you could add something like this to your .bashrc file (works on Linux and similar environments):
alias gtag='git tag -n99'
Then whenever you want to see your tags, you just type gtag
. Another advantage of going down the alias path (either git aliases or bash aliases or whatever) is you now have a spot already in place where you can add further customizations to how you personally, generally want to have your tags shown to you (like sorting them in certain ways as in my comment below, etc). Once you get over the hurtle of creating your first alias, you will now realize how easy it is to create more of them for other things you like to work in a customized way, like git log
, but let's save that one for a different question/answer.
It's far from pretty, but you could create a script or an alias that does something like this:
for c in $(git for-each-ref refs/tags/ --format='%(refname)'); do echo $c; git show --quiet "$c"; echo; done
Use --format option
git tag -l --format='%(tag) %(subject)'
Last tag message only:
git cat-file -p $(git rev-parse $(git tag -l | tail -n1)) | tail -n +6
git tag -l --format='%(contents)'
or
git for-each-ref refs/tags/ --format='%(contents)'
will output full annotation message for every tag (including signature if its signed).
%(contents:subject)
will output only first line%(contents:body)
will output annotation without first line and signature (useful text only)%(contents:signature)
will output only PGP-signatureSee more in man git-for-each-ref “Field names” section.
I prefer doing this on the command line, but if you don't mind a web interface and you use GitHub, you can visit https://github.com/user/repo/tags
and click on the "..." next to each tag to display its annotation.