<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<article lang="en" id="git-tag(1)">
<articleinfo>
    <title>git-tag(1)</title>
        <indexterm>
                <primary>git-tag(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-tag - Create, list, delete or verify a tag object signed with GPG</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<blockquote>
<literallayout><emphasis>git tag</emphasis> [-a | -s | -u &lt;key-id&gt;] [-f] [-m &lt;msg&gt; | -F &lt;file&gt;]
        &lt;name&gt; [&lt;commit&gt; | &lt;object&gt;]
<emphasis>git tag</emphasis> -d &lt;name&gt;&#8230;
<emphasis>git tag</emphasis> [-n[&lt;num&gt;]] -l [--contains &lt;commit&gt;] [&lt;pattern&gt;]
<emphasis>git tag</emphasis> -v &lt;name&gt;&#8230;</literallayout>
</blockquote>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>Adds a <emphasis>tag</emphasis> reference in <literal>.git/refs/tags/</literal></simpara>
<simpara>Unless <literal>-f</literal> is given, the tag must not yet exist in
<literal>.git/refs/tags/</literal> directory.</simpara>
<simpara>If one of <literal>-a</literal>, <literal>-s</literal>, or <literal>-u &lt;key-id&gt;</literal> is passed, the command
creates a <emphasis>tag</emphasis> object, and requires the tag message.  Unless
<literal>-m &lt;msg&gt;</literal> or <literal>-F &lt;file&gt;</literal> is given, an editor is started for the user to type
in the tag message.</simpara>
<simpara>If <literal>-m &lt;msg&gt;</literal> or <literal>-F &lt;file&gt;</literal> is given and <literal>-a</literal>, <literal>-s</literal>, and <literal>-u &lt;key-id&gt;</literal>
are absent, <literal>-a</literal> is implied.</simpara>
<simpara>Otherwise just the SHA1 object name of the commit object is
written (i.e. a lightweight tag).</simpara>
<simpara>A GnuPG signed tag object will be created when <literal>-s</literal> or <literal>-u
&lt;key-id&gt;</literal> is used.  When <literal>-u &lt;key-id&gt;</literal> is not used, the
committer identity for the current user is used to find the
GnuPG key for signing.</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
-a
</term>
<listitem>
<simpara>
        Make an unsigned, annotated tag object
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-s
</term>
<listitem>
<simpara>
        Make a GPG-signed tag, using the default e-mail address&#8217;s key
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-u &lt;key-id&gt;
</term>
<listitem>
<simpara>
        Make a GPG-signed tag, using the given key
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-f
</term>
<listitem>
<simpara>
        Replace an existing tag with the given name (instead of failing)
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-d
</term>
<listitem>
<simpara>
        Delete existing tags with the given names.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-v
</term>
<listitem>
<simpara>
        Verify the gpg signature of the given tag names.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-n&lt;num&gt;
</term>
<listitem>
<simpara>
        &lt;num&gt; specifies how many lines from the annotation, if any,
        are printed when using -l.
        The default is not to print any annotation lines.
        If no number is given to <literal>-n</literal>, only the first line is printed.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-l &lt;pattern&gt;
</term>
<listitem>
<simpara>
        List tags with names that match the given pattern (or all if no pattern is given).
        Typing "git tag" without arguments, also lists all tags.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--contains &lt;commit&gt;
</term>
<listitem>
<simpara>
        Only list tags which contain the specified commit.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-m &lt;msg&gt;
</term>
<listitem>
<simpara>
        Use the given tag message (instead of prompting).
        If multiple <literal>-m</literal> options are given, their values are
        concatenated as separate paragraphs.
        Implies <literal>-a</literal> if none of <literal>-a</literal>, <literal>-s</literal>, or <literal>-u &lt;key-id&gt;</literal>
        is given.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-F &lt;file&gt;
</term>
<listitem>
<simpara>
        Take the tag message from the given file.  Use <emphasis>-</emphasis> to
        read the message from the standard input.
        Implies <literal>-a</literal> if none of <literal>-a</literal>, <literal>-s</literal>, or <literal>-u &lt;key-id&gt;</literal>
        is given.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_configuration">
<title>CONFIGURATION</title>
<simpara>By default, <emphasis>git-tag</emphasis> in sign-with-default mode (-s) will use your
committer identity (of the form "Your Name &lt;<ulink url="mailto:your@email.address">your@email.address</ulink>&gt;") to
find a key.  If you want to use a different default key, you can specify
it in the repository configuration as follows:</simpara>
<literallayout>[user]
    signingkey = &lt;gpg-key-id&gt;</literallayout>
</simplesect>
<simplesect id="_discussion">
<title>DISCUSSION</title>
<simplesect id="_on_re_tagging">
<title>On Re-tagging</title>
<simpara>What should you do when you tag a wrong commit and you would
want to re-tag?</simpara>
<simpara>If you never pushed anything out, just re-tag it. Use "-f" to
replace the old one. And you&#8217;re done.</simpara>
<simpara>But if you have pushed things out (or others could just read
your repository directly), then others will have already seen
the old tag. In that case you can do one of two things:</simpara>
<orderedlist numeration="arabic">
<listitem>
<simpara>
The sane thing.
Just admit you screwed up, and use a different name. Others have
already seen one tag-name, and if you keep the same name, you
may be in the situation that two people both have "version X",
but they actually have <emphasis>different</emphasis> "X"'s.  So just call it "X.1"
and be done with it.
</simpara>
</listitem>
<listitem>
<simpara>
The insane thing.
You really want to call the new version "X" too, <emphasis>even though</emphasis>
others have already seen the old one. So just use <emphasis>git-tag -f</emphasis>
again, as if you hadn&#8217;t already published the old one.
</simpara>
</listitem>
</orderedlist>
<simpara>However, Git does <emphasis role="strong">not</emphasis> (and it should not) change tags behind
users back. So if somebody already got the old tag, doing a
<emphasis>git-pull</emphasis> on your tree shouldn&#8217;t just make them overwrite the old
one.</simpara>
<simpara>If somebody got a release tag from you, you cannot just change
the tag for them by updating your own one. This is a big
security issue, in that people MUST be able to trust their
tag-names.  If you really want to do the insane thing, you need
to just fess up to it, and tell people that you messed up. You
can do that by making a very public announcement saying:</simpara>
<literallayout>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 inconvenience.</literallayout>
<simpara>Does this seem a bit complicated?  It <emphasis role="strong">should</emphasis> be. There is no
way that it would be correct to just "fix" it behind peoples
backs. People need to know that their tags might have been
changed.</simpara>
</simplesect>
<simplesect id="_on_automatic_following">
<title>On Automatic following</title>
<simpara>If you are following somebody else&#8217;s tree, you are most likely
using tracking branches (<literal>refs/heads/origin</literal> in traditional
layout, or <literal>refs/remotes/origin/master</literal> in the separate-remote
layout).  You usually want the tags from the other end.</simpara>
<simpara>On the other hand, if you are fetching because you would want a
one-shot merge from somebody else, you typically do not want to
get tags from there.  This happens more often for people near
the toplevel but not limited to them.  Mere mortals when pulling
from each other do not necessarily want to automatically get
private anchor point tags from the other person.</simpara>
<simpara>You would notice "please pull" messages on the mailing list says
repo URL and branch name alone.  This is designed to be easily
cut&amp;pasted to a <emphasis>git-fetch</emphasis> command line:</simpara>
<literallayout>Linus, please pull from

        git://git..../proj.git master

to get the following updates...</literallayout>
<simpara>becomes:</simpara>
<literallayout>$ git pull git://git..../proj.git master</literallayout>
<simpara>In such a case, you do not want to automatically follow other&#8217;s
tags.</simpara>
<simpara>One important aspect of git is it is distributed, and being
distributed largely means there is no inherent "upstream" or
"downstream" in the system.  On the face of it, the above
example might seem to indicate that the tag namespace is owned
by upper echelon of people and tags only flow downwards, but
that is not the case.  It only shows that the usage pattern
determines who are interested in whose tags.</simpara>
<simpara>A one-shot pull is a sign that a commit history is now crossing
the boundary between one circle of people (e.g. "people who are
primarily interested in the networking part of the kernel") who may
have their own set of tags (e.g. "this is the third release
candidate from the networking group to be proposed for general
consumption 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 used
internally in the former group (that is what "internal" means).
That is why it is desirable not to follow tags automatically in
this case.</simpara>
<simpara>It may well be that among networking people, they may want to
exchange the tags internal to their group, but in that workflow
they are most likely tracking with each other&#8217;s progress by
having tracking branches.  Again, the heuristic to automatically
follow such tags is a good thing.</simpara>
</simplesect>
<simplesect id="_on_backdating_tags">
<title>On Backdating Tags</title>
<simpara>If you have imported some changes from another VCS and would like
to add tags for major releases of your work, it is useful to be able
to specify the date to embed inside of the tag object.  The data in
the tag object affects, for example, the ordering of tags in the
gitweb interface.</simpara>
<simpara>To set the date used in future tag objects, set the environment
variable GIT_COMMITTER_DATE to one or more of the date and time.  The
date and time can be specified in a number of ways; the most common
is "YYYY-MM-DD HH:MM".</simpara>
<simpara>An example follows.</simpara>
<literallayout>$ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1</literallayout>
</simplesect>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;,
Junio C Hamano &lt;<ulink url="mailto:gitster@pobox.com">gitster@pobox.com</ulink>&gt; and Chris Wright &lt;<ulink url="mailto:chrisw@osdl.org">chrisw@osdl.org</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_documentation">
<title>Documentation</title>
<simpara>Documentation by David Greaves, Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
</simplesect>
</article>
