Git - git tag

git

How can we use git tag?

# tag a revision
git tag v1.0.0                      # make current HEAD known as "v1.0.0"
git tag interesting v1.4.4-g730996f # tag a specific revision (not HEAD)

git tag -a name

What is the purpose of the 'git tag -l' option?

It lists tags.

git tag -l

How can we show the tag message?

git show tag

What is the purpose of Tagging?

With the use of tags, Git can flag certain points in a project’s history as being significant.

How can we display a list of tags?

git tag

How can we list only particular types of tags?

git tag -l “v1.2.9”

What are the two categories of tags?

  1. Lightweight: A lightweight tag is a pointer to a particular commit – like a branch.
  2. Annotated: An annotated tag is stored in the Git database as a full object, containing a tagging message, tagger name and email, and tag date. Annotated Tags can also undergo signing and verification with GNU Privacy Guard (GPG). The best practice is to use annotated tags when possible, to allow for storage of valuable information and privacy safeguards.

How can we create an annotated tag?

To create an annotated tag, use -a with the git tag command.

git tag -a v2.0 -m “my version 2.0”

How can we create a lightweight tag?

A lightweight tag for commits only holds a checksum. To create a lightweight tag, simply utilize the git tag command without using -a, -s, or -m.

git tag v2.5

How can we share tags?

Users must push tags to shared servers after creation because, by default, the git push command does not send tags to remote servers. To push tags to shared servers, use the git push origin [tagname] command.

To push all of your tags at once, use the --tags option for the git push command:

git push origin --tags

Anyone who pulls from your repository or clones it will also receive all of your tags.

How can we do a 'tag checkout'?

Because you cannot move tags around, they cannot be checked out in Git. However, you can create a new branch at a specific tag with the git checkout -b [branchname][tagname] command.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License