You can simply use the git tag
command to list all the git tags associated with a repository, for example, like so:
git tag
This would produce an output like the following (depending, of course, on the tags in your repository):
v1.0.0 v1.0.1 v2.0.0-alpha # ...
Make sure you run git fetch --all --tags
prior, if your local is not in sync with your remote repository.
You can find some useful shortcuts to common workflows below:
- Show Tags With Commit Hashes;
- List Specific Tags That Match the Given Pattern;
- List All Tags With Descriptions.
#Show Tags With Commit Hashes
You can use the git show-ref
command (in the following way) to show tags with their corresponding commits:
git show-ref --tags -d
This would produce an output like the following (depending, of course, on the tags in your repository):
f8696acb9c94f5972b0b1aa502b4a12b9257b9dc refs/tags/v1.0.0 0de6e1d8336c9a5f85c69d324f14a675d5c56a2c refs/tags/v1.0.1 bba2c8984973cf74ed726a5a26f8f0baf0a6c9a2 refs/tags/v2.0.0-alpha # ...
#List Specific Tags That Match the Given Pattern
You can list all tags matching a given pattern by using the -l
flag (--list
) followed by the pattern, for example, like so:
git tag -l 'v1.*'
This would list all the tags starting with "v1.".
#List All Tags With Descriptions
To see the annotation message along with the tag (or the first commit message line if the tag is not annotated), you can use the -n
flag, like so:
git tag -n
You may, optionally, limit the annotation to the first "n" lines by simply appending the number after the -n
flag. For example, to show only the first five lines of annotations you would use the following command:
git tag -n5
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.