NAME

git-tag - Create, list, delete or verify a tag object signed with GPG

SYNOPSIS

  1. git tag [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>] [-e]
  2. <tagname> [<commit> | <object>]
  3. git tag -d <tagname>…​
  4. git tag [-n[<num>]] -l [--contains <commit>] [--no-contains <commit>]
  5. [--points-at <object>] [--column[=<options>] | --no-column]
  6. [--create-reflog] [--sort=<key>] [--format=<format>]
  7. [--[no-]merged [<commit>]] [<pattern>…​]
  8. 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.programis 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

  • -s

  • —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.gpgSignconfiguration variable if it exists, or disabled oder otherwise.See git-config[1].

  • —no-sign

  • Override tag.gpgSign configuration variable that isset to force each and every tag to be signed.

  • -u

  • —local-user=
  • Make a GPG-signed tag, using the given key.

  • -f

  • —force
  • Replace an existing tag with the given name (instead of failing)

  • -d

  • —delete
  • Delete existing tags with the given names.

  • -v

  • —verify
  • Verify the GPG signature of the given tag names.

  • -n

  • 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 the tag.sortvariable if it exists, or lexicographic order otherwise. Seegit-config[1].

  • —color[=]

  • Respect any colors specified in the —format option. The<when> field must be one of always, never, or auto (if<when> is absent, behave as if always was given).

  • -i

  • —ignore-case
  • Sorting and filtering tags are case insensitive.

  • —column[=]

  • —no-column
  • Display tag listing in columns. See configuration variablecolumn.tag for option syntax.—column and —no-columnwithout 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.

  • —no-contains []

  • Only list tags which don’t contain the specified commit (HEAD ifnot specified). Implies —list.

  • —merged []

  • Only list tags whose commits are reachable from the specifiedcommit (HEAD if not specified), incompatible with —no-merged.

  • —no-merged []

  • Only list tags whose commits are not reachable from the specifiedcommit (HEAD if not specified), incompatible with —merged.

  • —points-at

  • Only list tags of the given object (HEAD if notspecified). Implies —list.

  • -m

  • —message=
  • Use the given tag message (instead of prompting).If multiple -m options are given, their values areconcatenated as separate paragraphs.Implies -a if none of -a, -s, or -u <keyid>is given.

  • -F

  • —file=
  • Take the tag message from the given file. Use - toread the message from the standard input.Implies -a if none of -a, -s, or -u <keyid>is given.

  • -e

  • —edit
  • The message taken from file with -F and command line with-m are usually used as the tag message unmodified.This option lets you further edit the message taken from these sources.

  • —cleanup=

  • This option sets how the tag message is cleaned up.The can be one of verbatim, whitespace and strip. Thestrip mode is default. The verbatim mode does not change message atall, whitespace removes just leading/trailing whitespace lines andstrip removes both whitespace and commentary.

  • —create-reflog

  • Create a reflog for the tag. To globally enable reflogs for tags, seecore.logAllRefUpdates in git-config[1].The negated form —no-create-reflog only overrides an earlier—create-reflog, but currently does not negate the setting ofcore.logAllRefUpdates.

  • —format=

  • A string that interpolates %(fieldname) from a tag ref being shownand the object it points at. The format is the same asthat of git-for-each-ref[1]. When unspecified,defaults to %(refname:strip=2).

  • The name of the tag to create, delete, or describe.The new tag name must pass all checks defined bygit-check-ref-format[1]. Some of these checksmay restrict the characters allowed in a tag name.

  • The object that the new tag will refer to, usually a commit.Defaults to HEAD.

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:

  1. [user]
  2. 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:

  1. Ok, I messed up, and I pushed out an earlier version tagged as X. I
  2. then fixed something, and retagged the *fixed* tree as X again.
  3.  
  4. If you got the wrong tag, and want the new one, please delete
  5. the old one and fetch the new one by doing:
  6.  
  7. git tag -d X
  8. git fetch origin tag X
  9.  
  10. to get my updated tag.
  11.  
  12. You can test which tag you have by doing
  13.  
  14. git rev-parse X
  15.  
  16. which should return 0123456789abcdef.. if you have the new version.
  17.  
  18. 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:

  1. Linus, please pull from
  2.  
  3. git://git..../proj.git master
  4.  
  5. to get the following updates...

becomes:

  1. $ 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:

  1. $ 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.

  • RFC 2822

  • The standard email format as described by RFC 2822, for exampleThu, 07 Apr 2005 22:13:13 +0200.

  • ISO 8601

  • Time and date specified by the ISO 8601 standard, for example2005-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