Information Technology Reference
In-Depth Information
The state is not yet ready for the next release. Yet for some reason, you want to keep
the reference to the most recent commit using a lightweight tag. To create this, execute
the following command:
$ git tag temp-version
Your repository now contains seven commits
a
,
b
,
c
,
d
,
e
,
f
,
g
and two tags
v1.2.3
and
temp-version
.
How It Works
Git allows you to label arbitrary revisions with tags. There are two types of tags:
• Annotated
• Lightweight
Annotated tags are stored in your repository as objects. They contain the informa-
tion about:
• Author
• The date when the tag was created
• The comment
• The SHA-1 of the revision that is tagged
Lightweight tags contain just the SHA-1 of the revision they point to.
You can list all the tags, both annotated and lightweight, with this command:
$ git tag
Both types of tags are stored in the
.git/refs/tags
directory. Your
.git/
refs/tags
repository now contains two files. You can check this with:
$ ls .git/refs/tags
The files stored in
.git/refs/tags
contain the SHA-1 hashes. In the case of a
lightweight tag this hash points to the revision. For annotated tags, the hash points to
the tag object stored in the database.