Table of Contents

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:

A tag is an object in git.

Type

Annotated

Annotated tags :

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:

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:

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

git push --delete origin tagname
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:

Documentation / Reference