git/tag-list

List Tags

List all tags in the repository with optional filtering

git
tag
list
show
repository

Command

git tag

Explanation

The `git tag` command, when run without arguments, lists all tags in your repository. You can use filters and sort options to narrow down the list, such as `git tag -l "v1.*"` to show all tags starting with v1. Tags help organize repository history, marking releases, and identifying key milestones. Using the list command ensures visibility into what tags are available locally. Note that this only shows local tags unless you fetch from remote first.

Common Use Cases

  • Viewing available release versions
  • Checking tag presence before deployment
  • Filtering tags by naming convention

Best Practices

  • Use `git fetch --tags` to stay up to date with remote tags
  • Use naming conventions (v1.0.0, v2.0-beta) for clarity
  • Regularly review tags for version management and cleanup

Common Mistakes to Avoid

  • Expecting remote tags to appear without fetching
  • Not using filters when repository has many tags
  • Confusing tag names with branch names

Troubleshooting

Problem: Remote tags not showing locally

Solution: Run `git fetch --tags` to update local tag list from remote.

Problem: Too many tags cluttering output

Solution: Filter tags using patterns, e.g., `git tag -l "v2.*"`.

Examples

List all local tags

git tag

List all tags starting with v1

git tag -l "v1.*"

Fetch and update tags from the remote

git fetch --tags

View commit details for a specific tag

git show v1.0