Git - Tag

1 - About

tag 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.

3 - Type

3.1 - 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).

3.2 - 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)

4 - Property

4.1 - Name

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

5 - Management

5.1 - Create

5.1.1 - 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

5.1.2 - Lightweight

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

git tag v1.4

5.2 - 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

5.3 - 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

5.5 - Push

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

git push origin v1.5

where:

5.6 - Delete

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

5.7 - Checkout

5.7.1 - 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

5.7.2 - 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

6 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap