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.
21
22       By default (without --all or --tags) git describe only shows annotated
23       tags. For more information about creating annotated tags see the -a and
24       -s options to git-tag(1).
25
26       If the given object refers to a blob, it will be described as
27       <commit-ish>:<path>, such that the blob can be found at <path> in the
28       <commit-ish>, which itself describes the first commit in which this
29       blob occurs in a reverse revision walk from HEAD.
30

OPTIONS

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

EXAMPLES

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

SEARCH STRATEGY

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

BUGS

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

GIT

190       Part of the git(1) suite
191
192
193
194Git 2.18.1                        05/14/2019                   GIT-DESCRIBE(1)
Impressum