How To List Git Tags

In Git Repository, tags can be listed by using the Git Commands ie., ‘git tag’. Whenever you want to work with the list tags in git first make sure that the latest list from the remote repository has been fetched or not. Users require the git list tags of the repository to discover the needed commit point.

You can find different ways to obtain the list of git tags of the local and remote repository. In this tutorial, we have compiled various ways to find out the list git tags on your repository easily.

How to List All Tags in Git?

If you want to list all available tags in a project then make use of the git tag command (keep in mind that they will appear in alphabetical order):

$ git tag

This method of listing git tags is excellent for small projects, but bigger projects can have hundreds of tags, so you should require to filter them when searching for an important point in history. You can obtain tags including specific characters by adding an -l to the git tag command:

$ git tag -l "v2.0*"

Must View: How To Delete Local and Remote Tags on Git

List Local Git Tags

In order to list Git tags, you have to use the “git tag” command with no arguments.

$ git tag


You can also execute “git tag” with the “-n” option in order to have an extensive description of your tag list.

$ git tag -n

List Local Git Tags git-tag-n

Optionally, you can choose to specify a tag pattern with the “-l” option followed by the tag pattern.

$ git tag -l <pattern>

List Local Git Tags git-tag

Awesome, you have successfully listed tags on your Git repository!

List Remote Git Tags

As you already know, Git is a decentralized versioning system. As a result, you may have not fetched some tags that have been made available by other developers on your repository.

In order to list remote Git tags, you have to use the “git ls-remote” command with the “–tags” option and the name of your remote repository.

$ git ls-remote --tags <remote>

For example, if your remote name is “origin”, you will have to execute the following command.

$ git ls-remote --tags origin

53a7dcf1ca57e05d456321b406730b39dc8ed75e        refs/tags/v1.0
7a9ad7fd794bf52a11de43aacc6010978e6100d3        refs/tags/v2.0

Note: As you can see, by using the “ls-remote” command, you are presented with tags using the “refs” syntax that was already explained in our previous tutorials.

List and Sort Git Tags

Additionally, you can choose to list your tags and sort them following a lexical or a version sorting.

In order to list Git tags following a lexicographic order, you have to use the “git tag” command with the “–sort=refname” option and an additional tag pattern.

$ git tag -l --sort=refname <pattern>

List and Sort Git Tags git-tag-sort

Sorting by refname is not the only way of sorting Git tags.

You can also choose to sort your tags by versions: this way, your tag names will be treated as version numbers.

In order to list Git tags sorted by version numbers, you have to use the “git tag” command with the “–sort=version:refname” option and an additional tag pattern.

$ git tag -l --sort=-version:refname <pattern>

List and Sort Git Tags git-tag-2

Sorting most recent Git tags

In order to list and sort Git tags by their latest Git activity, you can use the “git tag” command with the “–sort=committerdate”.

$ git tag --sort=committerdate -l <pattern>

Sorting most recents Git tags committer

Congratulations, you successfully sorted your Git tags using the sort options!

Fetching Remote Tags Easily

Now that you know that some tags are available remotely, you may want to fetch your tags in order to list them locally.

To fetch tags from your remote repository, use “git fetch” with the “–all” and the “–tags” options.

$ git fetch --all --tags

Fetching origin
From git-repository
   53a7dc..7a9ad7    master     -> origin/master
 * [new tag]         v1.0       -> v1.0
 * [new tag]         v1.0       -> v2.0

Awesome, you fetched your tags from your distant repository!

Now, you can list them easily using the “git tag” command (with no arguments!)

$ git tag


Find Latest Git Tag Available

In order to find the latest Git tag available on your repository, you have to use the “git describe” command with the “–tags” option.

This way, you will be presented with the tag that is associated with the latest commit of your current checked-out branch.

$ git describe



From this tutorial, you discovered how you can easily list your Git tags, whether they are local or remote.

You also learned that you can use advanced sorting options in order to have your results sorted by recent date or version number.

We have other tutorials on Git tags, make sure to have a read:

Leave a Reply

Your email address will not be published. Required fields are marked *