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

DESCRIPTION

15       The command finds the most recent tag that is reachable from a commit.
16       If the tag points to the commit, then only the tag is shown. Otherwise,
17       it suffixes the tag name with the number of additional commits on top
18       of the tagged object and the abbreviated object name of the most recent
19       commit. The result is a "human-readable" object name which can also be
20       used to identify the commit to other git commands.
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 number of hexadecimal digits (which
60           will vary according to the number of objects in the repository with
61           a default of 7) of the abbreviated object name, use <n> digits, or
62           as many digits as needed to form a unique object name. An <n> of 0
63           will suppress long 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" + an
133       unambigous abbreviation for the tip commit of parent (which was
134       2414721b194453f058079d897d13c4e377f92dc6). The length of the
135       abbreviation scales as the repository grows, using the approximate
136       number of objects in the repository and a bit of math around the
137       birthday paradox, and defaults to a minimum of 7. The "g" prefix stands
138       for "git" and is used to allow describing the version of a software
139       depending on the SCM the software is managed with. This is useful in an
140       environment where people may use different SCMs.
141
142       Doing a git describe on a tag-name will just show the tag name:
143
144           [torvalds@g5 git]$ git describe v1.0.4
145           v1.0.4
146
147       With --all, the command can use branch heads as references, so the
148       output shows the reference path as well:
149
150           [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
151           tags/v1.0.0-21-g975b
152
153           [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
154           heads/lt/describe-7-g975b
155
156       With --abbrev set to 0, the command can be used to find the closest
157       tagname without any suffix:
158
159           [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
160           tags/v1.0.0
161
162       Note that the suffix you get if you type these commands today may be
163       longer than what Linus saw above when he ran these commands, as your
164       Git repository may have new commits whose object names begin with 975b
165       that did not exist back then, and "-g975b" suffix alone may not be
166       sufficient to disambiguate these commits.
167

SEARCH STRATEGY

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

BUGS

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

GIT

194       Part of the git(1) suite
195
196
197
198Git 2.36.1                        2022-05-05                   GIT-DESCRIBE(1)
Impressum