blob: 78b9808aa3a2f5fe2435ea188ac4e73508c2720a [file] [log] [blame]
Junio C Hamanoab008762005-12-28 02:33:001git-describe(1)
2===============
3
4NAME
5----
Junio C Hamano01078922006-03-10 00:31:476git-describe - Show the most recent tag that is reachable from a commit
Junio C Hamanoab008762005-12-28 02:33:007
8
9SYNOPSIS
10--------
Junio C Hamano0ecfa0f2009-11-10 22:13:2411[verse]
Junio C Hamanofce7c7e2008-07-02 03:06:3812'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...
Junio C Hamano446ed772009-11-10 22:02:2013'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
Junio C Hamanoab008762005-12-28 02:33:0014
15DESCRIPTION
16-----------
17The command finds the most recent tag that is reachable from a
Junio C Hamano2fbcd212008-05-14 22:26:0718commit. If the tag points to the commit, then only the tag is
19shown. Otherwise, it suffixes the tag name with the number of
20additional commits on top of the tagged object and the
21abbreviated object name of the most recent commit.
Junio C Hamanoab008762005-12-28 02:33:0022
Junio C Hamano7d06a8a2008-10-20 05:42:3323By default (without --all or --tags) `git describe` only shows
24annotated tags. For more information about creating annotated tags
25see the -a and -s options to linkgit:git-tag[1].
Junio C Hamanoab008762005-12-28 02:33:0026
27OPTIONS
28-------
Junio C Hamano9e395072008-07-31 22:11:2129<committish>...::
30Committish object names to describe.
Junio C Hamanoab008762005-12-28 02:33:0031
Junio C Hamano446ed772009-11-10 22:02:2032--dirty[=<mark>]::
33Describe the working tree.
34It means describe HEAD and appends <mark> (`-dirty` by
35default) if the working tree is dirty.
36
Junio C Hamanoab008762005-12-28 02:33:0037--all::
38Instead of using only the annotated tags, use any ref
Junio C Hamano7d06a8a2008-10-20 05:42:3339found in `.git/refs/`. This option enables matching
40any known branch, remote branch, or lightweight tag.
Junio C Hamanoab008762005-12-28 02:33:0041
42--tags::
43Instead of using only the annotated tags, use any tag
Junio C Hamano7d06a8a2008-10-20 05:42:3344found in `.git/refs/tags`. This option enables matching
45a lightweight (non-annotated) tag.
Junio C Hamanoab008762005-12-28 02:33:0046
Junio C Hamano5e284b42007-05-22 07:23:3747--contains::
48Instead of finding the tag that predates the commit, find
49the tag that comes after the commit, and thus contains it.
50Automatically implies --tags.
51
Junio C Hamanoab008762005-12-28 02:33:0052--abbrev=<n>::
Junio C Hamano22bcc112009-01-24 08:05:1853Instead of using the default 7 hexadecimal digits as the
Junio C Hamanoc21ab052009-10-31 04:03:5554abbreviated object name, use <n> digits, or as many digits
55as needed to form a unique object name. An <n> of 0
56will suppress long format, only showing the closest tag.
Junio C Hamanoab008762005-12-28 02:33:0057
Junio C Hamanoedd2b0a2007-01-15 06:12:4558--candidates=<n>::
59Instead of considering only the 10 most recent tags as
60candidates to describe the input committish consider
61up to <n> candidates. Increasing <n> above 10 will take
62slightly longer but may produce a more accurate result.
Junio C Hamano24bc09a2008-02-28 00:27:4463An <n> of 0 will cause only exact matches to be output.
64
65--exact-match::
66Only output exact matches (a tag directly references the
67supplied commit). This is a synonym for --candidates=0.
Junio C Hamanoedd2b0a2007-01-15 06:12:4568
69--debug::
70Verbosely display information about the searching strategy
71being employed to standard error. The tag name will still
72be printed to standard out.
Junio C Hamanoab008762005-12-28 02:33:0073
Junio C Hamano4f1d8c42008-03-03 02:01:1674--long::
75Always output the long format (the tag, the number of commits
76and the abbreviated commit name) even when it matches a tag.
77This is useful when you want to see parts of the commit object name
78in "describe" output, even when the commit in question happens to be
79a tagged version. Instead of just emitting the tag name, it will
Junio C Hamanoc21ab052009-10-31 04:03:5580describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
81that points at object deadbee....).
Junio C Hamano4f1d8c42008-03-03 02:01:1682
Junio C Hamano9c334152008-02-12 03:18:5283--match <pattern>::
84Only consider tags matching the given pattern (can be used to avoid
85leaking private tags made from the repository).
86
Junio C Hamanoeb415992008-06-08 22:49:4787--always::
88Show uniquely abbreviated commit object as fallback.
89
Junio C Hamanoab008762005-12-28 02:33:0090EXAMPLES
91--------
92
93With something like git.git current tree, I get:
94
Junio C Hamanofce7c7e2008-07-02 03:06:3895[torvalds@g5 git]$ git describe parent
Junio C Hamanoa890c4f2007-01-28 10:29:2196v1.0.4-14-g2414721
Junio C Hamanoab008762005-12-28 02:33:0097
98i.e. the current head of my "parent" branch is based on v1.0.4,
Junio C Hamano6efe3022009-01-13 16:47:5699but since it has a few commits on top of that,
Junio C Hamanoa890c4f2007-01-28 10:29:21100describe has added the number of additional commits ("14") and
101an abbreviated object name for the commit itself ("2414721")
102at the end.
103
104The number of additional commits is the number
105of commits which would be displayed by "git log v1.0.4..parent".
106The hash suffix is "-g" + 7-char abbreviation for the tip commit
107of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
Junio C Hamanoab008762005-12-28 02:33:00108
Junio C Hamanoba4b9282008-07-06 05:20:31109Doing a 'git-describe' on a tag-name will just show the tag name:
Junio C Hamanoab008762005-12-28 02:33:00110
Junio C Hamanofce7c7e2008-07-02 03:06:38111[torvalds@g5 git]$ git describe v1.0.4
Junio C Hamanoab008762005-12-28 02:33:00112v1.0.4
113
114With --all, the command can use branch heads as references, so
115the output shows the reference path as well:
116
117[torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
Junio C Hamanoa890c4f2007-01-28 10:29:21118tags/v1.0.0-21-g975b
Junio C Hamanoab008762005-12-28 02:33:00119
Junio C Hamanoc21ab052009-10-31 04:03:55120[torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
Junio C Hamanoa890c4f2007-01-28 10:29:21121heads/lt/describe-7-g975b
122
123With --abbrev set to 0, the command can be used to find the
124closest tagname without any suffix:
125
126[torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
127tags/v1.0.0
Junio C Hamanoab008762005-12-28 02:33:00128
Junio C Hamanoc21ab052009-10-31 04:03:55129Note that the suffix you get if you type these commands today may be
Junio C Hamanoa1f86332009-11-05 05:28:43130longer than what Linus saw above when he ran these commands, as your
Junio C Hamanoc21ab052009-10-31 04:03:55131git repository may have new commits whose object names begin with
132975b that did not exist back then, and "-g975b" suffix alone may not
133be sufficient to disambiguate these commits.
134
135
Junio C Hamanoedd2b0a2007-01-15 06:12:45136SEARCH STRATEGY
137---------------
138
Junio C Hamanoba4b9282008-07-06 05:20:31139For each committish supplied, 'git-describe' will first look for
Junio C Hamanoedd2b0a2007-01-15 06:12:45140a tag which tags exactly that commit. Annotated tags will always
141be preferred over lightweight tags, and tags with newer dates will
142always be preferred over tags with older dates. If an exact match
143is found, its name will be output and searching will stop.
144
Junio C Hamanoba4b9282008-07-06 05:20:31145If an exact match was not found, 'git-describe' will walk back
Junio C Hamanoedd2b0a2007-01-15 06:12:45146through the commit history to locate an ancestor commit which
147has been tagged. The ancestor's tag will be output along with an
148abbreviation of the input committish's SHA1.
149
150If multiple tags were found during the walk then the tag which
151has the fewest commits different from the input committish will be
152selected and output. Here fewest commits different is defined as
Junio C Hamanofce7c7e2008-07-02 03:06:38153the number of commits which would be shown by `git log tag..input`
Junio C Hamanoedd2b0a2007-01-15 06:12:45154will be the smallest number of commits possible.
155
Junio C Hamanoab008762005-12-28 02:33:00156
157Author
158------
159Written by Linus Torvalds <torvalds@osdl.org>, but somewhat
Junio C Hamano0868a302008-07-22 09:20:44160butchered by Junio C Hamano <gitster@pobox.com>. Later significantly
Junio C Hamanoa890c4f2007-01-28 10:29:21161updated by Shawn Pearce <spearce@spearce.org>.
Junio C Hamanoab008762005-12-28 02:33:00162
163Documentation
164--------------
165Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
166
167GIT
168---
Junio C Hamanof7c042d2008-06-06 22:50:53169Part of the linkgit:git[1] suite