1GIT-DESCRIBE(1) Git Manual GIT-DESCRIBE(1)
2
3
4
6 git-describe - Show the most recent tag that is reachable from a commit
7
9 git describe [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...
10 git describe [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
11
12
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
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 refs/ namespace. This option enables matching any known branch,
35 remote-tracking branch, or lightweight tag.
36
37 --tags
38 Instead of using only the annotated tags, use any tag found in
39 refs/tags namespace. 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 glob(7) pattern, excluding
80 the "refs/tags/" prefix. This can be used to avoid leaking private
81 tags from the repository.
82
83 --always
84 Show uniquely abbreviated commit object as fallback.
85
87 With something like git.git current tree, I get:
88
89 [torvalds@g5 git]$ git describe parent
90 v1.0.4-14-g2414721
91
92 i.e. the current head of my "parent" branch is based on v1.0.4, but
93 since it has a few commits on top of that, describe has added the
94 number of additional commits ("14") and an abbreviated object name for
95 the commit itself ("2414721") at the end.
96
97 The number of additional commits is the number of commits which would
98 be displayed by "git log v1.0.4..parent". The hash suffix is "-g" +
99 7-char abbreviation for the tip commit of parent (which was
100 2414721b194453f058079d897d13c4e377f92dc6). The "g" prefix stands for
101 "git" and is used to allow describing the version of a software
102 depending on the SCM the software is managed with. This is useful in an
103 environment where people may use different SCMs.
104
105 Doing a git describe on a tag-name will just show the tag name:
106
107 [torvalds@g5 git]$ git describe v1.0.4
108 v1.0.4
109
110 With --all, the command can use branch heads as references, so the
111 output shows the reference path as well:
112
113 [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
114 tags/v1.0.0-21-g975b
115
116 [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
117 heads/lt/describe-7-g975b
118
119 With --abbrev set to 0, the command can be used to find the closest
120 tagname without any suffix:
121
122 [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
123 tags/v1.0.0
124
125 Note that the suffix you get if you type these commands today may be
126 longer than what Linus saw above when he ran these commands, as your
127 Git repository may have new commits whose object names begin with 975b
128 that did not exist back then, and "-g975b" suffix alone may not be
129 sufficient to disambiguate these commits.
130
132 For each committish supplied, git describe will first look for a tag
133 which tags exactly that commit. Annotated tags will always be preferred
134 over lightweight tags, and tags with newer dates will always be
135 preferred over tags with older dates. If an exact match is found, its
136 name will be output and searching will stop.
137
138 If an exact match was not found, git describe will walk back through
139 the commit history to locate an ancestor commit which has been tagged.
140 The ancestor’s tag will be output along with an abbreviation of the
141 input committish’s SHA-1.
142
143 If multiple tags were found during the walk then the tag which has the
144 fewest commits different from the input committish will be selected and
145 output. Here fewest commits different is defined as the number of
146 commits which would be shown by git log tag..input will be the smallest
147 number of commits possible.
148
150 Part of the git(1) suite
151
152
153
154Git 1.8.3.1 11/19/2018 GIT-DESCRIBE(1)