Jump to content

How do I use git tags?

Linux Hint

Recommended Posts

Git Tags are specific reference points in the Git history. Git tags are used to capture the specific point in the history that is further used to point to a released version. A tag does not change like a branch. They don’t have a further history of commits after being created.  Most people use this feature to mark some release points like (v1.0,…v4.0, and so on). In simple words, Git Tags are used to give some meaningful name to a particular in the git project repository. Suppose two users decide to tag their project code for access later.

In this article, we will discuss the concept of Git tags and how the git tag command does work. We will cover various kinds of tags, how to create new tags, tag listing, and deletion of a tag, and more in this article. A few commands we have executed on the Ubuntu 20.04 system, which we will elaborate on in the rest of the section.

Create a new Tag

There are following two different types of Git tags:

  1. Annotated tags
  2. Lightweight tags

Annotated tags

The annotated tags are saved as a full object in the database of Git. These types of tags store some extra metadata information such as the name of the tagger, tagger email id, and date. Annotated tags stores with a tagging message. It is best practice suggested in git is to store git tags in the form of annotated tags over lightweight. Using the annotated tags, you can store all the associated meta-data in the database.

To create an annotated tag, open the terminal application by pressing Ctrl+Alt+t and run the following command:

$ git tag -a 'Release_1_0' -m 'Tagged basic string operation code' HEAD


In the above command, we have tagged the current HEAD by using the git tag command. The user provides a tag name ‘Release_1_0’ with the -a option, and the tag message is provided with the –m option.

Lightweight tags

This type of tags is used for ‘bookmarks’ to a commit; Lightweight tags are just a name or a specific pointer to a commit. Lightweight tags are useful for quick link creation to relevant commits.

The following command is used to create lightweight tags:

$ git tag <tag_name>


In the following example, let’s suppose we have created a lightweight tag with the name ‘Release_1_0’.

$ git tag Release_1_0

These types of tags are stored in the current working .git project repository.

View Tags

Once you have created tags, you can show tag details by using the following command:

$ git show Release_1_0


In the above command, we have printed the tag ‘Release_1_0’ details. In the following image, the tag details are displayed:

Listing Tags

You can also display all the tags names by using the following Git tag command with option –l:

$ git tag -l


Removing or Delete Tags

First, to list all store tags in a repository, run the below-given command:

$ git tag

Now, using the following command, you can remove or delete tags from the remote as well as the local repository.

$ git tag -d Release_1_0



We have learned how to use Git tags in this article. Tagging is a useful feature through which you can create a clone image of a Git repo. You can give a better, some meaningful name to a specific git project. According to your convenience, you can create two different types of tags, annotated or lightweight, which we have discussed above. I hope now you have a better understanding of the usage of Git tags in your Git project repo.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...