основное руководство Git для разработчиков (A Git core tutorial for developers)
TAGGING A VERSION
In Git, there are two kinds of tags, a "light" one, and an
"annotated tag".
A "light" tag is technically nothing more than a branch, except
we put it in the .git/refs/tags/
subdirectory instead of calling
it a head
. So the simplest form of tag involves nothing more than
$ git tag my-first-tag
which just writes the current HEAD
into the
.git/refs/tags/my-first-tag
file, after which point you can then
use this symbolic name for that particular state. You can, for
example, do
$ git diff my-first-tag
to diff your current state against that tag which at this point
will obviously be an empty diff, but if you continue to develop
and commit stuff, you can use your tag as an "anchor-point" to
see what has changed since you tagged it.
An "annotated tag" is actually a real Git object, and contains
not only a pointer to the state you want to tag, but also a small
tag name and message, along with optionally a PGP signature that
says that yes, you really did that tag. You create these
annotated tags with either the -a
or -s
flag to git tag:
$ git tag -s <tagname>
which will sign the current HEAD
(but you can also give it
another argument that specifies the thing to tag, e.g., you could
have tagged the current mybranch
point by using git tag <tagname>
mybranch
).
You normally only do signed tags for major releases or things
like that, while the light-weight tags are useful for any marking
you want to do — any time you decide that you want to remember a
certain point, just create a private tag for it, and you have a
nice symbolic name for the state at that point.