Git Create Tag Guide {Annotated and Lightweight} – phoenixNAP


Git tags are highlights in project development that are used to denote specific points in the project history. Tags usually mark a feature version, but they can also indicate confirmations.

Git tags are similar to Git branches, except that you can’t make changes to a tag after creation.

In this tutorial, you’ll learn how to create tags in Git.



  • installed (see how to install Git on CentOS, Ubuntu, macOS, Windows)
  • A

Git repository. What are tags in Git

? Git tags

represent specific benchmarks in the history of a software development project. Use Git tags to mark a commit and highlight it for future reference.

You can tag any commit, but typically users tag release versions. For example, a tag can mark the initial stable version of a project, such as v1.0. Once a tag is created, it includes all changes made to the project and acts as a git branch that does not change. Git tags are great for comparing commits.

How to create a tag in Git?

There are two types of Git


  • Annotated tags. They contain metadata about the user creating the tag, such as name, email address, and date.
  • Light labels. It does not contain additional metadata. It simply points to a compromise.

The following sections explain how to create each type of tag in Git, as well as how to relate a tag to a commit.

Create an annotated tag

Annotated tags are typically used for public versions, as they contain detailed metadata about the tagger and an optional message about the confirmation.

Create an annotated tag by specifying the -a flag with the git tag command: git tag -a

[tag name] For

[tag name] , specify the name of the tag. While there are no limitations to setting a tag name, the best practice is to follow semantic versioning and name the tag as follows:

v[major]. [minor]. [patch]

  • [major]. The current public version number; Modifications are not backward compatible.
  • [minor]. The current functional version. Modifications are backward compatible.
  • [patch]. An increment for bug fixes or patches that do not affect the overall functionality of the software.

For example:

git tag -a v1.2

The command creates a new annotated tag identified as v1.2. Next, the default text editor configured to prompt for a description of the label opens:

Alternatively, use the -m flag to add a message immediately instead of asking. For example:

git tag -a v1.5 -m “Version v1.5 created”

The command creates the label with the message provided

. Create a lightweight tag A light tag

does not contain additional metadata found in annotated tags

. Create

a lightweight


when the version is not public and you need private or temporary tags with only basic tag information. Some Git commands for naming objects, such as git describes, ignore light tags by default.

Create a lightweight tag

with the following syntax

: git tag [tag name]

For example:

The command creates a new Git tag named v1.0.

Create a Git tag for a commit Create a Git


for a given commit from Git history by specifying the commit SHA. Get

the commit SHA by running: git log -oneline

After you get the commit SHA, create a tag with the following syntax

: git tag [tag name] [commit SHA]

For example:

The command

creates a tag for the commit specified in the Git history

. Send tags to remote repository The git push command does not automatically send


to a remote repository. To make local tags available in a remote repository, specify the -tags: git push -tags flag The command inserts all local tags into the connected remote repository. Alternatively, to push a specific tag to a remote repository, use the following syntax: Git Push [tag name] How to view tags in Git? To


all Git tags, Run the following command:


Tag The command generates all tags created in the project, listed in alphabetical order. If the list of tags is long, search for the tag names by specifying the -l flag and generating only the tags for a specific version.

For example:

git tag -l “v1.2*”

The output contains only tags that begin with v1.2. See our guide to Git list tags for more information on enumerating git tags from local or remote repositories.


This tutorial showed you how to create annotated and lightweight Git tags for your project. For more Git guides, see How to rename tags in Git, revert last commit, resolve merge conflicts in Git, or restore a deleted repository.

Contact US