NAME
git-tag - Create, list, delete or verify a tag object signed with GPG
SYNOPSIS
- git tag [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>] [-e]
- <tagname> [<commit> | <object>]
- git tag -d <tagname>…
- git tag [-n[<num>]] -l [--contains <commit>] [--no-contains <commit>]
- [--points-at <object>] [--column[=<options>] | --no-column]
- [--create-reflog] [--sort=<key>] [--format=<format>]
- [--[no-]merged [<commit>]] [<pattern>…]
- git tag -v [--format=<format>] <tagname>…
DESCRIPTION
Add a tag reference in refs/tags/
, unless -d/-l/-v
is givento delete, list or verify tags.
Unless -f
is given, the named tag must not yet exist.
If one of -a
, -s
, or -u <keyid>
is passed, the commandcreates a tag object, and requires a tag message. Unless-m <msg>
or -F <file>
is given, an editor is started for the user to typein the tag message.
If -m <msg>
or -F <file>
is given and -a
, -s
, and -u <keyid>
are absent, -a
is implied.
Otherwise, a tag reference that points directly at the given object(i.e., a lightweight tag) is created.
A GnuPG signed tag object will be created when -s
or -u<keyid>
is used. When -u <keyid>
is not used, thecommitter identity for the current user is used to find theGnuPG key for signing. The configuration variable gpg.program
is used to specify custom GnuPG binary.
Tag objects (created with -a
, -s
, or -u
) are called "annotated"tags; they contain a creation date, the tagger name and e-mail, atagging message, and an optional GnuPG signature. Whereas a"lightweight" tag is simply a name for an object (usually a commitobject).
Annotated tags are meant for release while lightweight tags are meantfor private or temporary object labels. For this reason, some gitcommands for naming objects (like git describe
) will ignorelightweight tags by default.
OPTIONS
- -a
- —annotate
Make an unsigned, annotated tag object
- —sign
Make a GPG-signed tag, using the default e-mail address’s key.The default behavior of tag GPG-signing is controlled by
tag.gpgSign
configuration variable if it exists, or disabled oder otherwise.See git-config[1].Override
tag.gpgSign
configuration variable that isset to force each and every tag to be signed.- —local-user=
Make a GPG-signed tag, using the given key.
- —force
Replace an existing tag with the given name (instead of failing)
- —delete
Delete existing tags with the given names.
- —verify
Verify the GPG signature of the given tag names.
specifies how many lines from the annotation, if any,are printed when using -l. Implies —list
.
The default is not to print any annotation lines.If no number is given to -n
, only the first line is printed.If the tag is not annotated, the commit message is displayed instead.
- -l
- —list
- List tags. With optional
<pattern>…
, e.g.git tag —list'v-*'
, list only the tags that match the pattern(s).
Running "git tag" without arguments also lists all tags. The patternis a shell wildcard (i.e., matched using fnmatch(3)). Multiplepatterns may be given; if any of them matches, the tag is shown.
This option is implicitly supplied if any other list-like option suchas —contains
is provided. See the documentation for each of thoseoptions for details.
- —sort=
Sort based on the key given. Prefix
-
to sort indescending order of the value. You may use the —sort=optionmultiple times, in which case the last key becomes the primarykey. Also supports "version:refname" or "v:refname" (tagnames are treated as versions). The "version:refname" sortorder can also be affected by the "versionsort.suffix"configuration variable.The keys supported are the same as those in git for-each-ref
.Sort order defaults to the value configured for thetag.sort
variable if it exists, or lexicographic order otherwise. Seegit-config[1].Respect any colors specified in the
—format
option. The<when>
field must be one ofalways
,never
, orauto
(if<when>
is absent, behave as ifalways
was given).- —ignore-case
Sorting and filtering tags are case insensitive.
- —no-column
- Display tag listing in columns. See configuration variablecolumn.tag for option syntax.
—column
and—no-column
without options are equivalent to always and never respectively.
This option is only applicable when listing tags without annotation lines.
- —contains [
] Only list tags which contain the specified commit (HEAD if notspecified). Implies
—list
.Only list tags which don’t contain the specified commit (HEAD ifnot specified). Implies
—list
.Only list tags whose commits are reachable from the specifiedcommit (
HEAD
if not specified), incompatible with—no-merged
.Only list tags whose commits are not reachable from the specifiedcommit (
HEAD
if not specified), incompatible with—merged
.
CONFIGURATION
By default, git tag in sign-with-default mode (-s) will use yourcommitter identity (of the form Your Name <your@email.address>
) tofind a key. If you want to use a different default key, you can specifyit in the repository configuration as follows:
- [user]
- signingKey = <gpg-keyid>
pager.tag
is only respected when listing tags, i.e., when -l
isused or implied. The default is to use a pager.See git-config[1].
DISCUSSION
On Re-tagging
What should you do when you tag a wrong commit and you wouldwant to re-tag?
If you never pushed anything out, just re-tag it. Use "-f" toreplace the old one. And you’re done.
But if you have pushed things out (or others could just readyour repository directly), then others will have already seenthe old tag. In that case you can do one of two things:
The sane thing.Just admit you screwed up, and use a different name. Others havealready seen one tag-name, and if you keep the same name, youmay be in the situation that two people both have "version X",but they actually have different "X"'s. So just call it "X.1"and be done with it.
The insane thing.You really want to call the new version "X" too, _even though_others have already seen the old one. So just use _git tag -f_again, as if you hadn’t already published the old one.
However, Git does not (and it should not) change tags behindusers back. So if somebody already got the old tag, doing agit pull on your tree shouldn’t just make them overwrite the oldone.
If somebody got a release tag from you, you cannot just changethe tag for them by updating your own one. This is a bigsecurity issue, in that people MUST be able to trust theirtag-names. If you really want to do the insane thing, you needto just fess up to it, and tell people that you messed up. Youcan do that by making a very public announcement saying:
- Ok, I messed up, and I pushed out an earlier version tagged as X. I
- then fixed something, and retagged the *fixed* tree as X again.
- If you got the wrong tag, and want the new one, please delete
- the old one and fetch the new one by doing:
- git tag -d X
- git fetch origin tag X
- to get my updated tag.
- You can test which tag you have by doing
- git rev-parse X
- which should return 0123456789abcdef.. if you have the new version.
- Sorry for the inconvenience.
Does this seem a bit complicated? It should be. There is noway that it would be correct to just "fix" it automatically.People need to know that their tags might have been changed.
On Automatic following
If you are following somebody else’s tree, you are most likelyusing remote-tracking branches (eg. refs/remotes/origin/master
).You usually want the tags from the other end.
On the other hand, if you are fetching because you would want aone-shot merge from somebody else, you typically do not want toget tags from there. This happens more often for people nearthe toplevel but not limited to them. Mere mortals when pullingfrom each other do not necessarily want to automatically getprivate anchor point tags from the other person.
Often, "please pull" messages on the mailing list just providetwo pieces of information: a repo URL and a branch name; thisis designed to be easily cut&pasted at the end of a _git fetch_command line:
- Linus, please pull from
- git://git..../proj.git master
- to get the following updates...
becomes:
- $ git pull git://git..../proj.git master
In such a case, you do not want to automatically follow the otherperson’s tags.
One important aspect of Git is its distributed nature, whichlargely means there is no inherent "upstream" or"downstream" in the system. On the face of it, the aboveexample might seem to indicate that the tag namespace is ownedby the upper echelon of people and that tags only flow downwards, butthat is not the case. It only shows that the usage patterndetermines who are interested in whose tags.
A one-shot pull is a sign that a commit history is now crossingthe boundary between one circle of people (e.g. "people who areprimarily interested in the networking part of the kernel") who mayhave their own set of tags (e.g. "this is the third releasecandidate from the networking group to be proposed for generalconsumption with 2.6.21 release") to another circle of people(e.g. "people who integrate various subsystem improvements").The latter are usually not interested in the detailed tags usedinternally in the former group (that is what "internal" means).That is why it is desirable not to follow tags automatically inthis case.
It may well be that among networking people, they may want toexchange the tags internal to their group, but in that workflowthey are most likely tracking each other’s progress byhaving remote-tracking branches. Again, the heuristic to automaticallyfollow such tags is a good thing.
On Backdating Tags
If you have imported some changes from another VCS and would liketo add tags for major releases of your work, it is useful to be ableto specify the date to embed inside of the tag object; such data inthe tag object affects, for example, the ordering of tags in thegitweb interface.
To set the date used in future tag objects, set the environmentvariable GIT_COMMITTER_DATE (see the later discussion of possiblevalues; the most common form is "YYYY-MM-DD HH:MM").
For example:
- $ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1
DATE FORMATS
The GIT_AUTHOR_DATE
, GIT_COMMITTER_DATE
environment variablessupport the following date formats:
- Git internal format
It is
<unix timestamp> <time zone offset>
, where<unixtimestamp>
is the number of seconds since the UNIX epoch.<time zone offset>
is a positive or negative offset from UTC.For example CET (which is 1 hour ahead of UTC) is+0100
.The standard email format as described by RFC 2822, for example
Thu, 07 Apr 2005 22:13:13 +0200
.- Time and date specified by the ISO 8601 standard, for example
2005-04-07T22:13:13
. The parser accepts a space instead of theT
character as well.
NoteIn addition, the date part is accepted in the following formats:YYYY.MM.DD
, MM/DD/YYYY
and DD.MM.YYYY
.
SEE ALSO
git-check-ref-format[1].git-config[1].
GIT
Part of the git[1] suite