Git Object: Tag | Git Tag

Git Object: Tag


A git tag can be used to give a name to a git commit . For example, when you finish beta for version 1.0, you might want to tag the current state as “1.0beta”. The tag includes:

  • The name of the tag (such as 1.0beta).
  • A commit that the tag refers to (such as 126af20). If you don’t specify a particular commit you want to tag, the most recent commit will be used.
  • A tag message (such as “This is 1.0beta“).
  • The tagger’s name, email address and the time the tag was added.

Example tag

Let’s use the example git object store as shown in the git commit section:


When we last left off, we had done a git commit which created the second commit object (the orange oval in the upper right of the above diagram with hash 7fd2d16). To tag the current state of the repository, type:

$ git tag 1.0beta -m "This is 1.0beta"

The -m allows you to add the text that goes along with the tag. You can see the details of a tag:

$ git cat-file -p 1.0beta
object 7fd2d163886aad0ebdb72b0df4d6cd7153653257
type commit
tag 1.0beta
tagger Tim Flagg <> Wed Feb 16 14:09:13 2011 -0800
This is 1.0beta

To tag the very first commit that was done (the orange oval in the upper left with hash 126af20 listed under the orange oval), you can specify that commit as the last argument to git tag:

$ git tag -m "This is 1.0alpha" 1.0alpha 126af20


To get a list of tags:

$ git tag -l

To check out the files that were tagged 1.0alpha:

$ git checkout 1.0alpha

and poke around to see what was at that point in time.

To get back to the files from the 1.0beta tag:

$ git checkout 1.0beta

Tags Are Fast

Adding a tag to a git commit is very fast and simple: A git tag object is added to the git object store and the tagging operation is finished.

Contrast this with adding a tag to legacy version control systems, which result in much more behind-the-scenes work while you wait.

Other flavors of git tags

The above type of tags (1.0alpha and 1.0beta) are the most common:

  • They are annotated (as opposed to lightweight)
  • They are unsigned (as opposed to GPG-signed).

A lightweight tag is:

  • Not stored in the git object store the database.
  • Can’t be GPG-signed.

The gpg signature of a signed tag can be checked/verified by using the git tag -v command.

Recent Articles

Where Do I Get Git?

Where do you get git? We have the answer to that for Linux (Ubuntu, Debian, and Red Hat), Windows, and Apple OS as well as over 30 free git tutorials.

What is the deal with the Git Index? What is the Git Index?

The git "index" is where you place files you want committed to the git repository. Learn more about the git index and git commit by selecting this link.

What Every VCS Must do

Version Control System ("VCS") need to be able to provide to its users? GitGuys explains exactly what it needs to include and provides tutorials on Git.

Visualising Branches And Their Commits

We explain and discuss the use of the git show-branch, gitg, gitk and qgit in this Tutorial. Complete with examples.

“Tracking Branches” And “Remote-Tracking Branches”

Both Tracking Branches and Remote Tracking Branches are created on the git client when a git clone command is used.

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox