brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git tag -n lists your tags with their messages

Git
~/tips/tip-git-tag-n-show-annotations

git tag -n

Lists tags together with the first line of their annotation, so the list explains itself.

A plain git tag gives you a list of version numbers and nothing else. Add one letter and the tag messages come along.

git tag -n
git tag -n3 -l 'v1.*'

-n prints the first line of each tag’s annotation next to its name. With a number, as in -n3, you get that many lines. The manual says the default is to print no annotation lines, and that -n implies --list, so a pattern after -l still filters the output.

For a lightweight tag that has no annotation, git shows the commit message instead, so the output is never empty.

This pays off when your tags carry release notes. To get that, create annotated tags with git tag -a v1.2.0 -m "Short summary of the release" instead of lightweight ones. Then git tag -n works like a tiny changelog.

The caveat is that the message belongs to the annotated tag object, so it is only as good as the one you wrote at the time. Lightweight tags show whichever commit message they happen to point at, which may say nothing about a release.

Further reading: git-tag documentation

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link