By default git tag sorts alphabetically, which puts v1.10 before v1.9. That’s wrong for anyone reading it as version numbers.
git config --global tag.sort version:refname
Now git tag treats the tag names as versions and sorts v1.9 before v1.10. For a single command, there’s the option form, and a minus sign reverses the order so the newest comes first:
git tag --sort=-v:refname | head -5
v:refname is a short way to write version:refname. I like the reversed form for scripts that need the latest release tag.
Pre-releases can look odd. By default v2.0-rc1 sorts after v2.0, because it’s a longer string. The setting versionsort.suffix fixes that: git config --global versionsort.suffix -rc tells git that tags ending in -rc something come before the plain version.
The sort only looks at names. A tag called release-2026 next to v1.4 sorts by the text, not by date. If your tags aren’t consistent, --sort=-creatordate sorts by when they were made, which is often what you actually want to know.
Further reading: git-tag documentation, git-config documentation
Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more