Git - Tag

About

This page is about tagging in git

Git has the ability to tag specific points in history as being important. Typically this functionality is used to mark release points (v1.0, and so on).

Git uses two main types of tags:

  • By default, the git push command doesn’t transfer tags to remote servers.
  • You can't add a new commit to a tag.

A tag is an object in git.

Type

Annotated

Annotated tags :

  • are stored as full objects in the Git database.
  • are checksummed;
  • contain the tagger name, email, and date;
  • have a tagging message;
  • can be signed and verified with GNU Privacy Guard (GPG).

Lightweight

A lightweight tag is very much like a branch that doesn’t change – it’s just a pointer to a specific commit.

Lightweight tags are used:

  • to create a temporary tag
  • to not keep all tag meta information (as with the annotated tag version)

Property

Name

The tag name generally starts with a v and follow the semantic version: See Code Versioning - Versioning scheme

Management

Create

Annotated

git tag -a v1.4 9fceb02  -m "my version 1.4"

where:

  • -a means annotated
  • v1.4 is the tag name.
  • 9fceb02 is the commit checksum or a part of it. See commit log. Default to the last commit.
  • -m “my version 1.4” is the tagging message

Lightweight

To create a lightweight tag, don’t supply the -a, -s, or -m option.

git tag v1.4

Show

With show

git show v1.4
tag v1.4
Tagger: Ben Straub <[email protected]>
Date:   Sat May 3 20:19:12 2014 -0700

my version 1.4

commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <[email protected]>
Date:   Mon Mar 17 21:52:11 2008 -0700

    changed the version number

List

To lists the tags in alphabetical order

git tag

Github: for example for spark: https://api.github.com/repos/apache/spark/tags

With a pattern

git tag -l "v1.8.5*"
v1.8.5
v1.8.5-rc0

Push

By default, the git push command doesn’t transfer tags to remote servers.

git push origin v1.5

where:

Delete

  • Remote
git push --delete origin tagname
  • Local
git tag --delete tagname

Checkout

Checkout Tag

Checkout is not a really checkout as they can't be modified

git checkout tags/tagName
# example
git checkout tags/release-1.4.0-rc1

where release-1.4.0-rc1 is the tag name

Checkout Tag with branch creation

git checkout tags/v2.0.0 -b version2
Switched to a new branch 'version2'

where:

  • -b version2 gives to the branch the name version2
  • v2.0.0 is the tag name

Documentation / Reference





Discover More
Git - Detached HEAD

What means a DETACHED HEAD in git
Git - Fetch (Remote Repository Sync)

A fetch will sync information locally from a remote repository. It will receive missing objects from another repository. It will mostly git fetch: download new remote branch download all commits...
Git - Git (executable|command line)

The git executable where: --git-dir is the location of the repository files --work-tree is the location of the work tree Command Description add Add file contents to the index add--interactive...
Git - Local branch

A local branch is a branch that exists only on your computer. tracking branch There are two types of local branches: non-tracking local branches. They are not associated with any other branch....
Git - Objects (Database)

An object is the value in the entry of the git database key-value. All entities in git are objects. Objects are the entity of the Git file system. On the operating file system, the objects are stored...
Git - Show

git show is a general command line tool that shows information object where hash is the object hash for commits it shows the log message and textual diff. It also presents the merge commit in a...
Branches Git
Git - Branch

This page talks Branch management in Git. For Git, a branch is: a commit name (ref) that points to the last commit (head) leaf in the commit log (or log) that represents a commit chain Example...
Git - Refs

A ref (or reference) is a human-readable name given to a commit SHA-1 hash. When referring to a Git commit, you can refer it by name with a reference A Git reference can be rewritten to point to a new...



Share this page:
Follow us:
Task Runner