]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-describe.txt
builtin/describe: introduce --broken flag
[thirdparty/git.git] / Documentation / git-describe.txt
CommitLineData
c06818e2
JH
1git-describe(1)
2===============
3
4NAME
5----
25f600e1 6git-describe - Describe a commit using the most recent tag reachable from it
c06818e2
JH
7
8
9SYNOPSIS
10--------
c5b3e0f5 11[verse]
2bd07065 12'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...]
9f67d2e8 13'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
c06818e2
JH
14
15DESCRIPTION
16-----------
17The command finds the most recent tag that is reachable from a
b7893cde
IH
18commit. If the tag points to the commit, then only the tag is
19shown. Otherwise, it suffixes the tag name with the number of
20additional commits on top of the tagged object and the
21abbreviated object name of the most recent commit.
c06818e2 22
7e425c4f
SP
23By default (without --all or --tags) `git describe` only shows
24annotated tags. For more information about creating annotated tags
25see the -a and -s options to linkgit:git-tag[1].
c06818e2
JH
26
27OPTIONS
28-------
a8a5406a 29<commit-ish>...::
2bd07065 30 Commit-ish object names to describe. Defaults to HEAD if omitted.
c06818e2 31
9f67d2e8 32--dirty[=<mark>]::
b0176ce6
SB
33--broken[=<mark>]::
34 Describe the state of the working tree. When the working
35 tree matches HEAD, the output is the same as "git describe
36 HEAD". If the working tree has local modification "-dirty"
37 is appended to it. If a repository is corrupt and Git
38 cannot determine if there is local modification, Git will
39 error out, unless `--broken' is given, which appends
40 the suffix "-broken" instead.
9f67d2e8 41
c06818e2
JH
42--all::
43 Instead of using only the annotated tags, use any ref
831e61f8 44 found in `refs/` namespace. This option enables matching
29b9a66f 45 any known branch, remote-tracking branch, or lightweight tag.
c06818e2
JH
46
47--tags::
48 Instead of using only the annotated tags, use any tag
831e61f8 49 found in `refs/tags` namespace. This option enables matching
7e425c4f 50 a lightweight (non-annotated) tag.
c06818e2 51
23615708
SP
52--contains::
53 Instead of finding the tag that predates the commit, find
54 the tag that comes after the commit, and thus contains it.
55 Automatically implies --tags.
56
c06818e2 57--abbrev=<n>::
b938f62a 58 Instead of using the default 7 hexadecimal digits as the
492cf3f7
GA
59 abbreviated object name, use <n> digits, or as many digits
60 as needed to form a unique object name. An <n> of 0
61 will suppress long format, only showing the closest tag.
c06818e2 62
8713ab30
SP
63--candidates=<n>::
64 Instead of considering only the 10 most recent tags as
a8a5406a 65 candidates to describe the input commit-ish consider
8713ab30
SP
66 up to <n> candidates. Increasing <n> above 10 will take
67 slightly longer but may produce a more accurate result.
2c33f757
SP
68 An <n> of 0 will cause only exact matches to be output.
69
70--exact-match::
71 Only output exact matches (a tag directly references the
72 supplied commit). This is a synonym for --candidates=0.
8713ab30
SP
73
74--debug::
75 Verbosely display information about the searching strategy
76 being employed to standard error. The tag name will still
77 be printed to standard out.
c06818e2 78
518120e3
SB
79--long::
80 Always output the long format (the tag, the number of commits
81 and the abbreviated commit name) even when it matches a tag.
82 This is useful when you want to see parts of the commit object name
83 in "describe" output, even when the commit in question happens to be
84 a tagged version. Instead of just emitting the tag name, it will
492cf3f7
GA
85 describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
86 that points at object deadbee....).
518120e3 87
30ffa603 88--match <pattern>::
52291497
GP
89 Only consider tags matching the given `glob(7)` pattern,
90 excluding the "refs/tags/" prefix. This can be used to avoid
43f8080e
JK
91 leaking private tags from the repository. If given multiple times, a
92 list of patterns will be accumulated, and tags matching any of the
93 patterns will be considered. Use `--no-match` to clear and reset the
94 list of patterns.
30ffa603 95
77d21f29
JK
96--exclude <pattern>::
97 Do not consider tags matching the given `glob(7)` pattern, excluding
98 the "refs/tags/" prefix. This can be used to narrow the tag space and
99 find only tags matching some meaningful criteria. If given multiple
100 times, a list of patterns will be accumulated and tags matching any
101 of the patterns will be excluded. When combined with --match a tag will
102 be considered when it matches at least one --match pattern and does not
103 match any of the --exclude patterns. Use `--no-exclude` to clear and
104 reset the list of patterns.
105
a3800f66
SB
106--always::
107 Show uniquely abbreviated commit object as fallback.
108
e00dd1e9
MC
109--first-parent::
110 Follow only the first parent commit upon seeing a merge commit.
111 This is useful when you wish to not match tags on branches merged
112 in the history of the target commit.
113
c06818e2
JH
114EXAMPLES
115--------
116
117With something like git.git current tree, I get:
118
b1889c36 119 [torvalds@g5 git]$ git describe parent
1891261e 120 v1.0.4-14-g2414721
c06818e2
JH
121
122i.e. the current head of my "parent" branch is based on v1.0.4,
323b9db8 123but since it has a few commits on top of that,
1891261e
JH
124describe has added the number of additional commits ("14") and
125an abbreviated object name for the commit itself ("2414721")
126at the end.
127
128The number of additional commits is the number
129of commits which would be displayed by "git log v1.0.4..parent".
130The hash suffix is "-g" + 7-char abbreviation for the tip commit
131of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
846b8f68
MH
132The "g" prefix stands for "git" and is used to allow describing the version of
133a software depending on the SCM the software is managed with. This is useful
134in an environment where people may use different SCMs.
c06818e2 135
0b444cdb 136Doing a 'git describe' on a tag-name will just show the tag name:
c06818e2 137
b1889c36 138 [torvalds@g5 git]$ git describe v1.0.4
c06818e2
JH
139 v1.0.4
140
141With --all, the command can use branch heads as references, so
142the output shows the reference path as well:
143
144 [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
1891261e 145 tags/v1.0.0-21-g975b
c06818e2 146
492cf3f7 147 [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
1891261e
JH
148 heads/lt/describe-7-g975b
149
150With --abbrev set to 0, the command can be used to find the
151closest tagname without any suffix:
152
153 [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
154 tags/v1.0.0
c06818e2 155
492cf3f7 156Note that the suffix you get if you type these commands today may be
0a565de4 157longer than what Linus saw above when he ran these commands, as your
2de9b711 158Git repository may have new commits whose object names begin with
492cf3f7
GA
159975b that did not exist back then, and "-g975b" suffix alone may not
160be sufficient to disambiguate these commits.
161
162
8713ab30
SP
163SEARCH STRATEGY
164---------------
165
a8a5406a 166For each commit-ish supplied, 'git describe' will first look for
8713ab30
SP
167a tag which tags exactly that commit. Annotated tags will always
168be preferred over lightweight tags, and tags with newer dates will
169always be preferred over tags with older dates. If an exact match
170is found, its name will be output and searching will stop.
171
0b444cdb 172If an exact match was not found, 'git describe' will walk back
8713ab30
SP
173through the commit history to locate an ancestor commit which
174has been tagged. The ancestor's tag will be output along with an
bcf9626a 175abbreviation of the input commit-ish's SHA-1. If `--first-parent` was
e00dd1e9
MC
176specified then the walk will only consider the first parent of each
177commit.
8713ab30
SP
178
179If multiple tags were found during the walk then the tag which
a8a5406a 180has the fewest commits different from the input commit-ish will be
8713ab30 181selected and output. Here fewest commits different is defined as
483bc4f0 182the number of commits which would be shown by `git log tag..input`
8713ab30
SP
183will be the smallest number of commits possible.
184
c06818e2
JH
185GIT
186---
9e1f0a85 187Part of the linkgit:git[1] suite