1GIT-DESCRIBE(1)                   Git Manual                   GIT-DESCRIBE(1)
2
3
4

NAME

6       git-describe - Show the most recent tag that is reachable from a commit
7

SYNOPSIS

9       git describe [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...
10       git describe [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
11
12

DESCRIPTION

14       The command finds the most recent tag that is reachable from a commit.
15       If the tag points to the commit, then only the tag is shown. Otherwise,
16       it suffixes the tag name with the number of additional commits on top
17       of the tagged object and the abbreviated object name of the most recent
18       commit.
19
20       By default (without --all or --tags) git describe only shows annotated
21       tags. For more information about creating annotated tags see the -a and
22       -s options to git-tag(1).
23

OPTIONS

25       <committish>...
26           Committish object names to describe.
27
28       --dirty[=<mark>]
29           Describe the working tree. It means describe HEAD and appends
30           <mark> (-dirty by default) if the working tree is dirty.
31
32       --all
33           Instead of using only the annotated tags, use any ref found in
34           .git/refs/. This option enables matching any known branch, remote
35           branch, or lightweight tag.
36
37       --tags
38           Instead of using only the annotated tags, use any tag found in
39           .git/refs/tags. This option enables matching a lightweight
40           (non-annotated) tag.
41
42       --contains
43           Instead of finding the tag that predates the commit, find the tag
44           that comes after the commit, and thus contains it. Automatically
45           implies --tags.
46
47       --abbrev=<n>
48           Instead of using the default 7 hexadecimal digits as the
49           abbreviated object name, use <n> digits, or as many digits as
50           needed to form a unique object name. An <n> of 0 will suppress long
51           format, only showing the closest tag.
52
53       --candidates=<n>
54           Instead of considering only the 10 most recent tags as candidates
55           to describe the input committish consider up to <n> candidates.
56           Increasing <n> above 10 will take slightly longer but may produce a
57           more accurate result. An <n> of 0 will cause only exact matches to
58           be output.
59
60       --exact-match
61           Only output exact matches (a tag directly references the supplied
62           commit). This is a synonym for --candidates=0.
63
64       --debug
65           Verbosely display information about the searching strategy being
66           employed to standard error. The tag name will still be printed to
67           standard out.
68
69       --long
70           Always output the long format (the tag, the number of commits and
71           the abbreviated commit name) even when it matches a tag. This is
72           useful when you want to see parts of the commit object name in
73           "describe" output, even when the commit in question happens to be a
74           tagged version. Instead of just emitting the tag name, it will
75           describe such a commit as v1.2-0-gdeadbee (0th commit since tag
76           v1.2 that points at object deadbee....).
77
78       --match <pattern>
79           Only consider tags matching the given pattern (can be used to avoid
80           leaking private tags made from the repository).
81
82       --always
83           Show uniquely abbreviated commit object as fallback.
84

EXAMPLES

86       With something like git.git current tree, I get:
87
88           [torvalds@g5 git]$ git describe parent
89           v1.0.4-14-g2414721
90
91       i.e. the current head of my "parent" branch is based on v1.0.4, but
92       since it has a few commits on top of that, describe has added the
93       number of additional commits ("14") and an abbreviated object name for
94       the commit itself ("2414721") at the end.
95
96       The number of additional commits is the number of commits which would
97       be displayed by "git log v1.0.4..parent". The hash suffix is "-g" +
98       7-char abbreviation for the tip commit of parent (which was
99       2414721b194453f058079d897d13c4e377f92dc6). The "g" prefix stands for
100       "git" and is used to allow describing the version of a software
101       depending on the SCM the software is managed with. This is useful in an
102       environment where people may use different SCMs.
103
104       Doing a git describe on a tag-name will just show the tag name:
105
106           [torvalds@g5 git]$ git describe v1.0.4
107           v1.0.4
108
109       With --all, the command can use branch heads as references, so the
110       output shows the reference path as well:
111
112           [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
113           tags/v1.0.0-21-g975b
114
115           [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
116           heads/lt/describe-7-g975b
117
118       With --abbrev set to 0, the command can be used to find the closest
119       tagname without any suffix:
120
121           [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
122           tags/v1.0.0
123
124       Note that the suffix you get if you type these commands today may be
125       longer than what Linus saw above when he ran these commands, as your
126       git repository may have new commits whose object names begin with 975b
127       that did not exist back then, and "-g975b" suffix alone may not be
128       sufficient to disambiguate these commits.
129

SEARCH STRATEGY

131       For each committish supplied, git describe will first look for a tag
132       which tags exactly that commit. Annotated tags will always be preferred
133       over lightweight tags, and tags with newer dates will always be
134       preferred over tags with older dates. If an exact match is found, its
135       name will be output and searching will stop.
136
137       If an exact match was not found, git describe will walk back through
138       the commit history to locate an ancestor commit which has been tagged.
139       The ancestor’s tag will be output along with an abbreviation of the
140       input committish’s SHA1.
141
142       If multiple tags were found during the walk then the tag which has the
143       fewest commits different from the input committish will be selected and
144       output. Here fewest commits different is defined as the number of
145       commits which would be shown by git log tag..input will be the smallest
146       number of commits possible.
147

AUTHOR

149       Written by Linus Torvalds <torvalds@osdl.org[1]>, but somewhat
150       butchered by Junio C Hamano <gitster@pobox.com[2]>. Later significantly
151       updated by Shawn Pearce <spearce@spearce.org[3]>.
152

DOCUMENTATION

154       Documentation by David Greaves, Junio C Hamano and the git-list
155       <git@vger.kernel.org[4]>.
156

GIT

158       Part of the git(1) suite
159

NOTES

161        1. torvalds@osdl.org
162           mailto:torvalds@osdl.org
163
164        2. gitster@pobox.com
165           mailto:gitster@pobox.com
166
167        3. spearce@spearce.org
168           mailto:spearce@spearce.org
169
170        4. git@vger.kernel.org
171           mailto:git@vger.kernel.org
172
173
174
175Git 1.7.1                         08/16/2017                   GIT-DESCRIBE(1)
Impressum