6 git-describe - Show the most recent tag that is reachable from a commit
12 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...
13 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
17 The command finds the most recent tag that is reachable from a
18 commit. If the tag points to the commit, then only the tag is
19 shown. Otherwise, it suffixes the tag name with the number of
20 additional commits on top of the tagged object and the
21 abbreviated object name of the most recent commit.
23 By default (without --all or --tags) `git describe` only shows
24 annotated tags. For more information about creating annotated tags
25 see the -a and -s options to linkgit:git-tag[1].
30 Committish object names to describe.
33 Describe the working tree.
34 It means describe HEAD and appends <mark> (`-dirty` by
35 default) if the working tree is dirty.
38 Instead of using only the annotated tags, use any ref
39 found in `refs/` namespace. This option enables matching
40 any known branch, remote-tracking branch, or lightweight tag.
43 Instead of using only the annotated tags, use any tag
44 found in `refs/tags` namespace. This option enables matching
45 a lightweight (non-annotated) tag.
48 Instead of finding the tag that predates the commit, find
49 the tag that comes after the commit, and thus contains it.
50 Automatically implies --tags.
53 Instead of using the default 7 hexadecimal digits as the
54 abbreviated object name, use <n> digits, or as many digits
55 as needed to form a unique object name. An <n> of 0
56 will suppress long format, only showing the closest tag.
59 Instead of considering only the 10 most recent tags as
60 candidates to describe the input committish consider
61 up to <n> candidates. Increasing <n> above 10 will take
62 slightly longer but may produce a more accurate result.
63 An <n> of 0 will cause only exact matches to be output.
66 Only output exact matches (a tag directly references the
67 supplied commit). This is a synonym for --candidates=0.
70 Verbosely display information about the searching strategy
71 being employed to standard error. The tag name will still
72 be printed to standard out.
75 Always output the long format (the tag, the number of commits
76 and the abbreviated commit name) even when it matches a tag.
77 This is useful when you want to see parts of the commit object name
78 in "describe" output, even when the commit in question happens to be
79 a tagged version. Instead of just emitting the tag name, it will
80 describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
81 that points at object deadbee....).
84 Only consider tags matching the given `glob(7)` pattern,
85 excluding the "refs/tags/" prefix. This can be used to avoid
86 leaking private tags from the repository.
89 Show uniquely abbreviated commit object as fallback.
94 With something like git.git current tree, I get:
96 [torvalds@g5 git]$ git describe parent
99 i.e. the current head of my "parent" branch is based on v1.0.4,
100 but since it has a few commits on top of that,
101 describe has added the number of additional commits ("14") and
102 an abbreviated object name for the commit itself ("2414721")
105 The number of additional commits is the number
106 of commits which would be displayed by "git log v1.0.4..parent".
107 The hash suffix is "-g" + 7-char abbreviation for the tip commit
108 of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
109 The "g" prefix stands for "git" and is used to allow describing the version of
110 a software depending on the SCM the software is managed with. This is useful
111 in an environment where people may use different SCMs.
113 Doing a 'git describe' on a tag-name will just show the tag name:
115 [torvalds@g5 git]$ git describe v1.0.4
118 With --all, the command can use branch heads as references, so
119 the output shows the reference path as well:
121 [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
124 [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
125 heads/lt/describe-7-g975b
127 With --abbrev set to 0, the command can be used to find the
128 closest tagname without any suffix:
130 [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
133 Note that the suffix you get if you type these commands today may be
134 longer than what Linus saw above when he ran these commands, as your
135 Git repository may have new commits whose object names begin with
136 975b that did not exist back then, and "-g975b" suffix alone may not
137 be sufficient to disambiguate these commits.
143 For each committish supplied, 'git describe' will first look for
144 a tag which tags exactly that commit. Annotated tags will always
145 be preferred over lightweight tags, and tags with newer dates will
146 always be preferred over tags with older dates. If an exact match
147 is found, its name will be output and searching will stop.
149 If an exact match was not found, 'git describe' will walk back
150 through the commit history to locate an ancestor commit which
151 has been tagged. The ancestor's tag will be output along with an
152 abbreviation of the input committish's SHA-1.
154 If multiple tags were found during the walk then the tag which
155 has the fewest commits different from the input committish will be
156 selected and output. Here fewest commits different is defined as
157 the number of commits which would be shown by `git log tag..input`
158 will be the smallest number of commits possible.
162 Part of the linkgit:git[1] suite