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

NAME

6       git-describe - Give an object a human readable name based on an
7       available ref
8

SYNOPSIS

10       git describe [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...]
11       git describe [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
12       git describe <blob>
13
14

DESCRIPTION

16       The command finds the most recent tag that is reachable from a commit.
17       If the tag points to the commit, then only the tag is shown. Otherwise,
18       it suffixes the tag name with the number of additional commits on top
19       of the tagged object and the abbreviated object name of the most recent
20       commit. The result is a "human-readable" object name which can also be
21       used to identify the commit to other git commands.
22
23       By default (without --all or --tags) git describe only shows annotated
24       tags. For more information about creating annotated tags see the -a and
25       -s options to git-tag(1).
26
27       If the given object refers to a blob, it will be described as
28       <commit-ish>:<path>, such that the blob can be found at <path> in the
29       <commit-ish>, which itself describes the first commit in which this
30       blob occurs in a reverse revision walk from HEAD.
31

OPTIONS

33       <commit-ish>...
34           Commit-ish object names to describe. Defaults to HEAD if omitted.
35
36       --dirty[=<mark>], --broken[=<mark>]
37           Describe the state of the working tree. When the working tree
38           matches HEAD, the output is the same as "git describe HEAD". If the
39           working tree has local modification "-dirty" is appended to it. If
40           a repository is corrupt and Git cannot determine if there is local
41           modification, Git will error out, unless ‘--broken’ is given, which
42           appends the suffix "-broken" instead.
43
44       --all
45           Instead of using only the annotated tags, use any ref found in
46           refs/ namespace. This option enables matching any known branch,
47           remote-tracking branch, or lightweight tag.
48
49       --tags
50           Instead of using only the annotated tags, use any tag found in
51           refs/tags namespace. This option enables matching a lightweight
52           (non-annotated) tag.
53
54       --contains
55           Instead of finding the tag that predates the commit, find the tag
56           that comes after the commit, and thus contains it. Automatically
57           implies --tags.
58
59       --abbrev=<n>
60           Instead of using the default 7 hexadecimal digits as the
61           abbreviated object name, use <n> digits, or as many digits as
62           needed to form a unique object name. An <n> of 0 will suppress long
63           format, only showing the closest tag.
64
65       --candidates=<n>
66           Instead of considering only the 10 most recent tags as candidates
67           to describe the input commit-ish consider up to <n> candidates.
68           Increasing <n> above 10 will take slightly longer but may produce a
69           more accurate result. An <n> of 0 will cause only exact matches to
70           be output.
71
72       --exact-match
73           Only output exact matches (a tag directly references the supplied
74           commit). This is a synonym for --candidates=0.
75
76       --debug
77           Verbosely display information about the searching strategy being
78           employed to standard error. The tag name will still be printed to
79           standard out.
80
81       --long
82           Always output the long format (the tag, the number of commits and
83           the abbreviated commit name) even when it matches a tag. This is
84           useful when you want to see parts of the commit object name in
85           "describe" output, even when the commit in question happens to be a
86           tagged version. Instead of just emitting the tag name, it will
87           describe such a commit as v1.2-0-gdeadbee (0th commit since tag
88           v1.2 that points at object deadbee....).
89
90       --match <pattern>
91           Only consider tags matching the given glob(7) pattern, excluding
92           the "refs/tags/" prefix. If used with --all, it also considers
93           local branches and remote-tracking references matching the pattern,
94           excluding respectively "refs/heads/" and "refs/remotes/" prefix;
95           references of other types are never considered. If given multiple
96           times, a list of patterns will be accumulated, and tags matching
97           any of the patterns will be considered. Use --no-match to clear and
98           reset the list of patterns.
99
100       --exclude <pattern>
101           Do not consider tags matching the given glob(7) pattern, excluding
102           the "refs/tags/" prefix. If used with --all, it also does not
103           consider local branches and remote-tracking references matching the
104           pattern, excluding respectively "refs/heads/" and "refs/remotes/"
105           prefix; references of other types are never considered. If given
106           multiple times, a list of patterns will be accumulated and tags
107           matching any of the patterns will be excluded. When combined with
108           --match a tag will be considered when it matches at least one
109           --match pattern and does not match any of the --exclude patterns.
110           Use --no-exclude to clear and reset the list of patterns.
111
112       --always
113           Show uniquely abbreviated commit object as fallback.
114
115       --first-parent
116           Follow only the first parent commit upon seeing a merge commit.
117           This is useful when you wish to not match tags on branches merged
118           in the history of the target commit.
119

EXAMPLES

121       With something like git.git current tree, I get:
122
123           [torvalds@g5 git]$ git describe parent
124           v1.0.4-14-g2414721
125
126       i.e. the current head of my "parent" branch is based on v1.0.4, but
127       since it has a few commits on top of that, describe has added the
128       number of additional commits ("14") and an abbreviated object name for
129       the commit itself ("2414721") at the end.
130
131       The number of additional commits is the number of commits which would
132       be displayed by "git log v1.0.4..parent". The hash suffix is "-g" +
133       7-char abbreviation for the tip commit of parent (which was
134       2414721b194453f058079d897d13c4e377f92dc6). The "g" prefix stands for
135       "git" and is used to allow describing the version of a software
136       depending on the SCM the software is managed with. This is useful in an
137       environment where people may use different SCMs.
138
139       Doing a git describe on a tag-name will just show the tag name:
140
141           [torvalds@g5 git]$ git describe v1.0.4
142           v1.0.4
143
144       With --all, the command can use branch heads as references, so the
145       output shows the reference path as well:
146
147           [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
148           tags/v1.0.0-21-g975b
149
150           [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
151           heads/lt/describe-7-g975b
152
153       With --abbrev set to 0, the command can be used to find the closest
154       tagname without any suffix:
155
156           [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
157           tags/v1.0.0
158
159       Note that the suffix you get if you type these commands today may be
160       longer than what Linus saw above when he ran these commands, as your
161       Git repository may have new commits whose object names begin with 975b
162       that did not exist back then, and "-g975b" suffix alone may not be
163       sufficient to disambiguate these commits.
164

SEARCH STRATEGY

166       For each commit-ish supplied, git describe will first look for a tag
167       which tags exactly that commit. Annotated tags will always be preferred
168       over lightweight tags, and tags with newer dates will always be
169       preferred over tags with older dates. If an exact match is found, its
170       name will be output and searching will stop.
171
172       If an exact match was not found, git describe will walk back through
173       the commit history to locate an ancestor commit which has been tagged.
174       The ancestor’s tag will be output along with an abbreviation of the
175       input commit-ish’s SHA-1. If --first-parent was specified then the walk
176       will only consider the first parent of each commit.
177
178       If multiple tags were found during the walk then the tag which has the
179       fewest commits different from the input commit-ish will be selected and
180       output. Here fewest commits different is defined as the number of
181       commits which would be shown by git log tag..input will be the smallest
182       number of commits possible.
183

BUGS

185       Tree objects as well as tag objects not pointing at commits, cannot be
186       described. When describing blobs, the lightweight tags pointing at
187       blobs are ignored, but the blob is still described as
188       <committ-ish>:<path> despite the lightweight tag being favorable.
189

GIT

191       Part of the git(1) suite
192
193
194
195Git 2.21.0                        02/24/2019                   GIT-DESCRIBE(1)
Impressum