]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-tag.txt
Merge branch 'rs/mailinfo-lib' into maint
[thirdparty/git.git] / Documentation / git-tag.txt
CommitLineData
215a7ad1
JH
1git-tag(1)
2==========
2cf565c5
DG
3
4NAME
5----
453c1e85 6git-tag - Create, list, delete or verify a tag object signed with GPG
2cf565c5
DG
7
8
2cf565c5
DG
9SYNOPSIS
10--------
b867c7c2 11[verse]
340f2c5e 12'git tag' [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>]
b85e6c5f
NS
13 <tagname> [<commit> | <object>]
14'git tag' -d <tagname>...
ae7706b9 15'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]
df094741 16 [--column[=<options>] | --no-column] [--create-reflog] [--sort=<key>]
5242860f 17 [--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]
b85e6c5f 18'git tag' -v <tagname>...
2cf565c5
DG
19
20DESCRIPTION
21-----------
18b07930 22
831e61f8 23Add a tag reference in `refs/tags/`, unless `-d/-l/-v` is given
cfb5e6b2 24to delete, list or verify tags.
b7e438f9 25
831e61f8 26Unless `-f` is given, the named tag must not yet exist.
b7e438f9 27
340f2c5e 28If one of `-a`, `-s`, or `-u <keyid>` is passed, the command
cfb5e6b2 29creates a 'tag' object, and requires a tag message. Unless
62e09ce9 30`-m <msg>` or `-F <file>` is given, an editor is started for the user to type
bc162e40 31in the tag message.
b7e438f9 32
340f2c5e 33If `-m <msg>` or `-F <file>` is given and `-a`, `-s`, and `-u <keyid>`
995e8df4
DS
34are absent, `-a` is implied.
35
d5fa1f1a 36Otherwise just a tag reference for the SHA-1 object name of the commit object is
cfb5e6b2 37created (i.e. a lightweight tag).
bc162e40
LT
38
39A GnuPG signed tag object will be created when `-s` or `-u
340f2c5e 40<keyid>` is used. When `-u <keyid>` is not used, the
bc162e40 41committer identity for the current user is used to find the
0c5e70f0
JH
42GnuPG key for signing. The configuration variable `gpg.program`
43is used to specify custom GnuPG binary.
44
eeff891a 45Tag objects (created with `-a`, `-s`, or `-u`) are called "annotated"
29d55538
DS
46tags; they contain a creation date, the tagger name and e-mail, a
47tagging message, and an optional GnuPG signature. Whereas a
48"lightweight" tag is simply a name for an object (usually a commit
49object).
50
51Annotated tags are meant for release while lightweight tags are meant
52for private or temporary object labels. For this reason, some git
53commands for naming objects (like `git describe`) will ignore
54lightweight tags by default.
55
2cf565c5 56
d839091d
NW
57OPTIONS
58-------
59-a::
c97eff5a 60--annotate::
d839091d
NW
61 Make an unsigned, annotated tag object
62
63-s::
c97eff5a 64--sign::
0c5e70f0 65 Make a GPG-signed tag, using the default e-mail address's key.
d839091d 66
340f2c5e
MM
67-u <keyid>::
68--local-user=<keyid>::
0c5e70f0 69 Make a GPG-signed tag, using the given key.
d839091d
NW
70
71-f::
f7aec129 72--force::
d839091d
NW
73 Replace an existing tag with the given name (instead of failing)
74
75-d::
c97eff5a 76--delete::
453c1e85 77 Delete existing tags with the given names.
d839091d 78
0bc72abd 79-v::
c97eff5a 80--verify::
bc913167 81 Verify the GPG signature of the given tag names.
0bc72abd 82
3f36cbba 83-n<num>::
980ea5c5
MM
84 <num> specifies how many lines from the annotation, if any,
85 are printed when using -l.
86 The default is not to print any annotation lines.
62e09ce9 87 If no number is given to `-n`, only the first line is printed.
abfd5fa8 88 If the tag is not annotated, the commit message is displayed instead.
980ea5c5 89
b867c7c2 90-l <pattern>::
c97eff5a 91--list <pattern>::
588d0e83
JK
92 List tags with names that match the given pattern (or all if no
93 pattern is given). Running "git tag" without arguments also
94 lists all tags. The pattern is a shell wildcard (i.e., matched
95 using fnmatch(3)). Multiple patterns may be given; if any of
96 them matches, the tag is shown.
b867c7c2 97
b7cc53e9
KN
98--sort=<key>::
99 Sort based on the key given. Prefix `-` to sort in
100 descending order of the value. You may use the --sort=<key> option
101 multiple times, in which case the last key becomes the primary
102 key. Also supports "version:refname" or "v:refname" (tag
64f7a264
MH
103 names are treated as versions). The "version:refname" sort
104 order can also be affected by the
b7cc53e9
KN
105 "versionsort.prereleaseSuffix" configuration variable.
106 The keys supported are the same as those in `git for-each-ref`.
ae9f6311 107 Sort order defaults to the value configured for the `tag.sort`
64f7a264
MH
108 variable if it exists, or lexicographic order otherwise. See
109 linkgit:git-config[1].
9ef176b5 110
d96e3c15
NTND
111--column[=<options>]::
112--no-column::
113 Display tag listing in columns. See configuration variable
114 column.tag for option syntax.`--column` and `--no-column`
115 without options are equivalent to 'always' and 'never' respectively.
116+
117This option is only applicable when listing tags without annotation lines.
118
81966ab2
NTND
119--contains [<commit>]::
120 Only list tags which contain the specified commit (HEAD if not
121 specified).
32c35cfb 122
ae7706b9
TG
123--points-at <object>::
124 Only list tags of the given object.
125
d839091d 126-m <msg>::
c97eff5a 127--message=<msg>::
bd46c9a9 128 Use the given tag message (instead of prompting).
d99bf51a 129 If multiple `-m` options are given, their values are
bd46c9a9 130 concatenated as separate paragraphs.
340f2c5e 131 Implies `-a` if none of `-a`, `-s`, or `-u <keyid>`
995e8df4 132 is given.
d839091d 133
f79c73ce 134-F <file>::
c97eff5a 135--file=<file>::
f79c73ce
JS
136 Take the tag message from the given file. Use '-' to
137 read the message from the standard input.
340f2c5e 138 Implies `-a` if none of `-a`, `-s`, or `-u <keyid>`
995e8df4 139 is given.
2cf565c5 140
d3e05983
KS
141--cleanup=<mode>::
142 This option sets how the tag message is cleaned up.
143 The '<mode>' can be one of 'verbatim', 'whitespace' and 'strip'. The
144 'strip' mode is default. The 'verbatim' mode does not change message at
145 all, 'whitespace' removes just leading/trailing whitespace lines and
146 'strip' removes both whitespace and commentary.
147
144c76fa
DT
148--create-reflog::
149 Create a reflog for the tag.
150
b85e6c5f
NS
151<tagname>::
152 The name of the tag to create, delete, or describe.
153 The new tag name must pass all checks defined by
154 linkgit:git-check-ref-format[1]. Some of these checks
155 may restrict the characters allowed in a tag name.
156
dd686cd4
TR
157<commit>::
158<object>::
159 The object that the new tag will refer to, usually a commit.
160 Defaults to HEAD.
161
df094741
KN
162<format>::
163 A string that interpolates `%(fieldname)` from the object
164 pointed at by a ref being shown. The format is the same as
165 that of linkgit:git-for-each-ref[1]. When unspecified,
0571979b 166 defaults to `%(refname:strip=2)`.
dd686cd4 167
5242860f
KN
168--[no-]merged [<commit>]::
169 Only list tags whose tips are reachable, or not reachable
661c3e9b 170 if `--no-merged` is used, from the specified commit (`HEAD`
5242860f
KN
171 if not specified).
172
d67778ec
AP
173CONFIGURATION
174-------------
0b444cdb 175By default, 'git tag' in sign-with-default mode (-s) will use your
d595bdc1 176committer identity (of the form `Your Name <your@email.address>`) to
d67778ec
AP
177find a key. If you want to use a different default key, you can specify
178it in the repository configuration as follows:
179
86b9e017 180-------------------------------------
d67778ec 181[user]
340f2c5e 182 signingKey = <gpg-keyid>
86b9e017 183-------------------------------------
d67778ec 184
4853534e
JH
185
186DISCUSSION
187----------
188
189On Re-tagging
190~~~~~~~~~~~~~
191
192What should you do when you tag a wrong commit and you would
193want to re-tag?
194
195If you never pushed anything out, just re-tag it. Use "-f" to
196replace the old one. And you're done.
197
198But if you have pushed things out (or others could just read
199your repository directly), then others will have already seen
200the old tag. In that case you can do one of two things:
201
202. The sane thing.
203Just admit you screwed up, and use a different name. Others have
204already seen one tag-name, and if you keep the same name, you
205may be in the situation that two people both have "version X",
206but they actually have 'different' "X"'s. So just call it "X.1"
207and be done with it.
208
209. The insane thing.
210You really want to call the new version "X" too, 'even though'
0b444cdb 211others have already seen the old one. So just use 'git tag -f'
4853534e
JH
212again, as if you hadn't already published the old one.
213
06ada152 214However, Git does *not* (and it should not) change tags behind
46e56e81 215users back. So if somebody already got the old tag, doing a
0b444cdb 216'git pull' on your tree shouldn't just make them overwrite the old
4853534e
JH
217one.
218
219If somebody got a release tag from you, you cannot just change
220the tag for them by updating your own one. This is a big
221security issue, in that people MUST be able to trust their
222tag-names. If you really want to do the insane thing, you need
223to just fess up to it, and tell people that you messed up. You
224can do that by making a very public announcement saying:
225
226------------
227Ok, I messed up, and I pushed out an earlier version tagged as X. I
228then fixed something, and retagged the *fixed* tree as X again.
229
230If you got the wrong tag, and want the new one, please delete
231the old one and fetch the new one by doing:
232
233 git tag -d X
234 git fetch origin tag X
235
236to get my updated tag.
237
238You can test which tag you have by doing
239
240 git rev-parse X
241
242which should return 0123456789abcdef.. if you have the new version.
243
f1723ee6 244Sorry for the inconvenience.
4853534e
JH
245------------
246
247Does this seem a bit complicated? It *should* be. There is no
f1723ee6
MW
248way that it would be correct to just "fix" it automatically.
249People need to know that their tags might have been changed.
4853534e
JH
250
251
252On Automatic following
253~~~~~~~~~~~~~~~~~~~~~~
254
255If you are following somebody else's tree, you are most likely
8b3f3f84 256using remote-tracking branches (`refs/heads/origin` in traditional
4853534e
JH
257layout, or `refs/remotes/origin/master` in the separate-remote
258layout). You usually want the tags from the other end.
259
260On the other hand, if you are fetching because you would want a
261one-shot merge from somebody else, you typically do not want to
262get tags from there. This happens more often for people near
263the toplevel but not limited to them. Mere mortals when pulling
264from each other do not necessarily want to automatically get
265private anchor point tags from the other person.
266
f1723ee6
MW
267Often, "please pull" messages on the mailing list just provide
268two pieces of information: a repo URL and a branch name; this
269is designed to be easily cut&pasted at the end of a 'git fetch'
270command line:
4853534e
JH
271
272------------
273Linus, please pull from
274
275 git://git..../proj.git master
276
277to get the following updates...
278------------
279
280becomes:
281
282------------
283$ git pull git://git..../proj.git master
284------------
285
f1723ee6
MW
286In such a case, you do not want to automatically follow the other
287person's tags.
4853534e 288
2de9b711 289One important aspect of Git is its distributed nature, which
f1723ee6 290largely means there is no inherent "upstream" or
4853534e
JH
291"downstream" in the system. On the face of it, the above
292example might seem to indicate that the tag namespace is owned
f1723ee6 293by the upper echelon of people and that tags only flow downwards, but
4853534e
JH
294that is not the case. It only shows that the usage pattern
295determines who are interested in whose tags.
296
297A one-shot pull is a sign that a commit history is now crossing
298the boundary between one circle of people (e.g. "people who are
d99bf51a 299primarily interested in the networking part of the kernel") who may
4853534e
JH
300have their own set of tags (e.g. "this is the third release
301candidate from the networking group to be proposed for general
302consumption with 2.6.21 release") to another circle of people
303(e.g. "people who integrate various subsystem improvements").
304The latter are usually not interested in the detailed tags used
305internally in the former group (that is what "internal" means).
306That is why it is desirable not to follow tags automatically in
307this case.
308
309It may well be that among networking people, they may want to
310exchange the tags internal to their group, but in that workflow
f1723ee6 311they are most likely tracking each other's progress by
8b3f3f84 312having remote-tracking branches. Again, the heuristic to automatically
4853534e
JH
313follow such tags is a good thing.
314
315
5040beff
MO
316On Backdating Tags
317~~~~~~~~~~~~~~~~~~
318
319If you have imported some changes from another VCS and would like
320to add tags for major releases of your work, it is useful to be able
f1723ee6 321to specify the date to embed inside of the tag object; such data in
5040beff
MO
322the tag object affects, for example, the ordering of tags in the
323gitweb interface.
324
325To set the date used in future tag objects, set the environment
f1723ee6
MW
326variable GIT_COMMITTER_DATE (see the later discussion of possible
327values; the most common form is "YYYY-MM-DD HH:MM").
5040beff 328
f1723ee6 329For example:
5040beff
MO
330
331------------
055b6615 332$ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1
5040beff
MO
333------------
334
f1723ee6 335include::date-formats.txt[]
5040beff 336
b85e6c5f
NS
337SEE ALSO
338--------
339linkgit:git-check-ref-format[1].
b150794d 340linkgit:git-config[1].
b85e6c5f 341
2cf565c5
DG
342GIT
343---
9e1f0a85 344Part of the linkgit:git[1] suite