BudiBadu Logo
Samplebadu

Git by Example: Tag Listing

2.43.0

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.1

Explanation

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 -l with wildcards to filter results
  • Use -n to see tag messages
  • Helps manage large numbers of versions

Code Breakdown

2
The basic command to see all available tags in your local repository.
10
Filters the list. The asterisk (*) acts as a wildcard, matching any characters. This is great for grouping versions.
17
Shows the first line of the annotation message (or the commit message for lightweight tags), providing context for each tag.