1GIT-TAG(1) Git Manual GIT-TAG(1)
2
3
4
6 git-tag - Create, list, delete or verify a tag object signed with GPG
7
9 git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]
10 <tagname> [<commit> | <object>]
11 git tag -d <tagname>...
12 git tag [-n[<num>]] -l [--contains <commit>] [<pattern>]
13 git tag -v <tagname>...
14
15
17 Adds a tag reference in .git/refs/tags/.
18
19 Unless -f is given, the tag must not yet exist in .git/refs/tags/
20 directory.
21
22 If one of -a, -s, or -u <key-id> is passed, the command creates a tag
23 object, and requires the tag message. Unless -m <msg> or -F <file> is
24 given, an editor is started for the user to type in the tag message.
25
26 If -m <msg> or -F <file> is given and -a, -s, and -u <key-id> are
27 absent, -a is implied.
28
29 Otherwise just the SHA1 object name of the commit object is written
30 (i.e. a lightweight tag).
31
32 A GnuPG signed tag object will be created when -s or -u <key-id> is
33 used. When -u <key-id> is not used, the committer identity for the
34 current user is used to find the GnuPG key for signing.
35
37 -a
38 Make an unsigned, annotated tag object
39
40 -s
41 Make a GPG-signed tag, using the default e-mail address’s key
42
43 -u <key-id>
44 Make a GPG-signed tag, using the given key
45
46 -f, --force
47 Replace an existing tag with the given name (instead of failing)
48
49 -d
50 Delete existing tags with the given names.
51
52 -v
53 Verify the gpg signature of the given tag names.
54
55 -n<num>
56 <num> specifies how many lines from the annotation, if any, are
57 printed when using -l. The default is not to print any annotation
58 lines. If no number is given to -n, only the first line is printed.
59 If the tag is not annotated, the commit message is displayed
60 instead.
61
62 -l <pattern>
63 List tags with names that match the given pattern (or all if no
64 pattern is given). Typing "git tag" without arguments, also lists
65 all tags.
66
67 --contains <commit>
68 Only list tags which contain the specified commit.
69
70 -m <msg>
71 Use the given tag message (instead of prompting). If multiple -m
72 options are given, their values are concatenated as separate
73 paragraphs. Implies -a if none of -a, -s, or -u <key-id> is given.
74
75 -F <file>
76 Take the tag message from the given file. Use - to read the message
77 from the standard input. Implies -a if none of -a, -s, or -u
78 <key-id> is given.
79
80 <tagname>
81 The name of the tag to create, delete, or describe. The new tag
82 name must pass all checks defined by git-check-ref-format(1). Some
83 of these checks may restrict the characters allowed in a tag name.
84
86 By default, git tag in sign-with-default mode (-s) will use your
87 committer identity (of the form "Your Name <your@email.address[1]>") to
88 find a key. If you want to use a different default key, you can specify
89 it in the repository configuration as follows:
90
91 [user]
92 signingkey = <gpg-key-id>
93
94
96 On Re-tagging
97 What should you do when you tag a wrong commit and you would want to
98 re-tag?
99
100 If you never pushed anything out, just re-tag it. Use "-f" to replace
101 the old one. And you’re done.
102
103 But if you have pushed things out (or others could just read your
104 repository directly), then others will have already seen the old tag.
105 In that case you can do one of two things:
106
107 1. The sane thing. Just admit you screwed up, and use a different
108 name. Others have already seen one tag-name, and if you keep the
109 same name, you may be in the situation that two people both have
110 "version X", but they actually have different "X"´s. So just call
111 it "X.1" and be done with it.
112
113 2. The insane thing. You really want to call the new version "X" too,
114 even though others have already seen the old one. So just use git
115 tag -f again, as if you hadn’t already published the old one.
116
117 However, Git does not (and it should not) change tags behind users
118 back. So if somebody already got the old tag, doing a git pull on your
119 tree shouldn’t just make them overwrite the old one.
120
121 If somebody got a release tag from you, you cannot just change the tag
122 for them by updating your own one. This is a big security issue, in
123 that people MUST be able to trust their tag-names. If you really want
124 to do the insane thing, you need to just fess up to it, and tell people
125 that you messed up. You can do that by making a very public
126 announcement saying:
127
128 Ok, I messed up, and I pushed out an earlier version tagged as X. I
129 then fixed something, and retagged the *fixed* tree as X again.
130
131 If you got the wrong tag, and want the new one, please delete
132 the old one and fetch the new one by doing:
133
134 git tag -d X
135 git fetch origin tag X
136
137 to get my updated tag.
138
139 You can test which tag you have by doing
140
141 git rev-parse X
142
143 which should return 0123456789abcdef.. if you have the new version.
144
145 Sorry for inconvenience.
146
147
148 Does this seem a bit complicated? It should be. There is no way that it
149 would be correct to just "fix" it behind peoples backs. People need to
150 know that their tags might have been changed.
151
152 On Automatic following
153 If you are following somebody else’s tree, you are most likely using
154 tracking branches (refs/heads/origin in traditional layout, or
155 refs/remotes/origin/master in the separate-remote layout). You usually
156 want the tags from the other end.
157
158 On the other hand, if you are fetching because you would want a
159 one-shot merge from somebody else, you typically do not want to get
160 tags from there. This happens more often for people near the toplevel
161 but not limited to them. Mere mortals when pulling from each other do
162 not necessarily want to automatically get private anchor point tags
163 from the other person.
164
165 You would notice "please pull" messages on the mailing list says repo
166 URL and branch name alone. This is designed to be easily cut&pasted to
167 a git fetch command line:
168
169 Linus, please pull from
170
171 git://git..../proj.git master
172
173 to get the following updates...
174
175
176 becomes:
177
178 $ git pull git://git..../proj.git master
179
180
181 In such a case, you do not want to automatically follow other’s tags.
182
183 One important aspect of git is it is distributed, and being distributed
184 largely means there is no inherent "upstream" or "downstream" in the
185 system. On the face of it, the above example might seem to indicate
186 that the tag namespace is owned by upper echelon of people and tags
187 only flow downwards, but that is not the case. It only shows that the
188 usage pattern determines who are interested in whose tags.
189
190 A one-shot pull is a sign that a commit history is now crossing the
191 boundary between one circle of people (e.g. "people who are primarily
192 interested in the networking part of the kernel") who may have their
193 own set of tags (e.g. "this is the third release candidate from the
194 networking group to be proposed for general consumption with 2.6.21
195 release") to another circle of people (e.g. "people who integrate
196 various subsystem improvements"). The latter are usually not interested
197 in the detailed tags used internally in the former group (that is what
198 "internal" means). That is why it is desirable not to follow tags
199 automatically in this case.
200
201 It may well be that among networking people, they may want to exchange
202 the tags internal to their group, but in that workflow they are most
203 likely tracking with each other’s progress by having tracking branches.
204 Again, the heuristic to automatically follow such tags is a good thing.
205
206 On Backdating Tags
207 If you have imported some changes from another VCS and would like to
208 add tags for major releases of your work, it is useful to be able to
209 specify the date to embed inside of the tag object. The data in the tag
210 object affects, for example, the ordering of tags in the gitweb
211 interface.
212
213 To set the date used in future tag objects, set the environment
214 variable GIT_COMMITTER_DATE to one or more of the date and time. The
215 date and time can be specified in a number of ways; the most common is
216 "YYYY-MM-DD HH:MM".
217
218 An example follows.
219
220 $ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1
221
222
224 git-check-ref-format(1).
225
227 Written by Linus Torvalds <torvalds@osdl.org[2]>, Junio C Hamano
228 <gitster@pobox.com[3]> and Chris Wright <chrisw@osdl.org[4]>.
229
231 Documentation by David Greaves, Junio C Hamano and the git-list
232 <git@vger.kernel.org[5]>.
233
235 Part of the git(1) suite
236
238 1. your@email.address
239 mailto:your@email.address
240
241 2. torvalds@osdl.org
242 mailto:torvalds@osdl.org
243
244 3. gitster@pobox.com
245 mailto:gitster@pobox.com
246
247 4. chrisw@osdl.org
248 mailto:chrisw@osdl.org
249
250 5. git@vger.kernel.org
251 mailto:git@vger.kernel.org
252
253
254
255Git 1.7.1 08/16/2017 GIT-TAG(1)