Git by Example: Tag Listing
Learn how to view and filter the tags in your repository. This example covers listing all tags, searching with wildcards, and viewing tag messages.
Code
# 1. List all tags
git tag
# Output:
# v0.9
# v1.0
# v1.1
# 2. Search for tags matching a pattern
git tag -l "v1.*"
# Output:
# v1.0
# v1.1
# 3. List tags with their messages
git tag -n
# Output:
# v0.9 Beta release
# v1.0 (no message)
# v1.1 Release version 1.1Explanation
As your project grows, you may accumulate dozens or hundreds of tags. The git tag command allows you to list and filter these tags to find exactly what you are looking for. By default, typing git tag lists the tags in alphabetical order, which might not always be the order they were created.
If you are looking for a specific series of tags, such as all the 1.x releases, you can use the -l or --list option with a wildcard pattern. For example, git tag -l "v1.8.5*" would find all patch versions of 1.8.5.
Another useful flag is -n, which displays the tag message alongside the tag name. This is helpful for getting a quick overview of what each release represents without having to inspect each tag individually.
- Lists tags alphabetically by default
- Use
-lwith wildcards to filter results - Use
-nto see tag messages - Helps manage large numbers of versions

