]>
Commit | Line | Data |
---|---|---|
c06818e2 JH |
1 | git-describe(1) |
2 | =============== | |
3 | ||
4 | NAME | |
5 | ---- | |
25f600e1 | 6 | git-describe - Describe a commit using the most recent tag reachable from it |
c06818e2 JH |
7 | |
8 | ||
9 | SYNOPSIS | |
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 | |
15 | DESCRIPTION | |
16 | ----------- | |
17 | The command finds the most recent tag that is reachable from a | |
b7893cde IH |
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. | |
c06818e2 | 22 | |
7e425c4f SP |
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]. | |
c06818e2 JH |
26 | |
27 | OPTIONS | |
28 | ------- | |
a8a5406a | 29 | <commit-ish>...:: |
2bd07065 | 30 | Commit-ish object names to describe. Defaults to HEAD if omitted. |
c06818e2 | 31 | |
9f67d2e8 JP |
32 | --dirty[=<mark>]:: |
33 | Describe the working tree. | |
34 | It means describe HEAD and appends <mark> (`-dirty` by | |
35 | default) if the working tree is dirty. | |
36 | ||
c06818e2 JH |
37 | --all:: |
38 | Instead of using only the annotated tags, use any ref | |
831e61f8 | 39 | found in `refs/` namespace. This option enables matching |
29b9a66f | 40 | any known branch, remote-tracking branch, or lightweight tag. |
c06818e2 JH |
41 | |
42 | --tags:: | |
43 | Instead of using only the annotated tags, use any tag | |
831e61f8 | 44 | found in `refs/tags` namespace. This option enables matching |
7e425c4f | 45 | a lightweight (non-annotated) tag. |
c06818e2 | 46 | |
23615708 SP |
47 | --contains:: |
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. | |
51 | ||
c06818e2 | 52 | --abbrev=<n>:: |
b938f62a | 53 | Instead of using the default 7 hexadecimal digits as the |
492cf3f7 GA |
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. | |
c06818e2 | 57 | |
8713ab30 SP |
58 | --candidates=<n>:: |
59 | Instead of considering only the 10 most recent tags as | |
a8a5406a | 60 | candidates to describe the input commit-ish consider |
8713ab30 SP |
61 | up to <n> candidates. Increasing <n> above 10 will take |
62 | slightly longer but may produce a more accurate result. | |
2c33f757 SP |
63 | An <n> of 0 will cause only exact matches to be output. |
64 | ||
65 | --exact-match:: | |
66 | Only output exact matches (a tag directly references the | |
67 | supplied commit). This is a synonym for --candidates=0. | |
8713ab30 SP |
68 | |
69 | --debug:: | |
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. | |
c06818e2 | 73 | |
518120e3 SB |
74 | --long:: |
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 | |
492cf3f7 GA |
80 | describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2 |
81 | that points at object deadbee....). | |
518120e3 | 82 | |
30ffa603 | 83 | --match <pattern>:: |
52291497 GP |
84 | Only consider tags matching the given `glob(7)` pattern, |
85 | excluding the "refs/tags/" prefix. This can be used to avoid | |
43f8080e JK |
86 | leaking private tags from the repository. If given multiple times, a |
87 | list of patterns will be accumulated, and tags matching any of the | |
88 | patterns will be considered. Use `--no-match` to clear and reset the | |
89 | list of patterns. | |
30ffa603 | 90 | |
a3800f66 SB |
91 | --always:: |
92 | Show uniquely abbreviated commit object as fallback. | |
93 | ||
e00dd1e9 MC |
94 | --first-parent:: |
95 | Follow only the first parent commit upon seeing a merge commit. | |
96 | This is useful when you wish to not match tags on branches merged | |
97 | in the history of the target commit. | |
98 | ||
c06818e2 JH |
99 | EXAMPLES |
100 | -------- | |
101 | ||
102 | With something like git.git current tree, I get: | |
103 | ||
b1889c36 | 104 | [torvalds@g5 git]$ git describe parent |
1891261e | 105 | v1.0.4-14-g2414721 |
c06818e2 JH |
106 | |
107 | i.e. the current head of my "parent" branch is based on v1.0.4, | |
323b9db8 | 108 | but since it has a few commits on top of that, |
1891261e JH |
109 | describe has added the number of additional commits ("14") and |
110 | an abbreviated object name for the commit itself ("2414721") | |
111 | at the end. | |
112 | ||
113 | The number of additional commits is the number | |
114 | of commits which would be displayed by "git log v1.0.4..parent". | |
115 | The hash suffix is "-g" + 7-char abbreviation for the tip commit | |
116 | of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`). | |
846b8f68 MH |
117 | The "g" prefix stands for "git" and is used to allow describing the version of |
118 | a software depending on the SCM the software is managed with. This is useful | |
119 | in an environment where people may use different SCMs. | |
c06818e2 | 120 | |
0b444cdb | 121 | Doing a 'git describe' on a tag-name will just show the tag name: |
c06818e2 | 122 | |
b1889c36 | 123 | [torvalds@g5 git]$ git describe v1.0.4 |
c06818e2 JH |
124 | v1.0.4 |
125 | ||
126 | With --all, the command can use branch heads as references, so | |
127 | the output shows the reference path as well: | |
128 | ||
129 | [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2 | |
1891261e | 130 | tags/v1.0.0-21-g975b |
c06818e2 | 131 | |
492cf3f7 | 132 | [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^ |
1891261e JH |
133 | heads/lt/describe-7-g975b |
134 | ||
135 | With --abbrev set to 0, the command can be used to find the | |
136 | closest tagname without any suffix: | |
137 | ||
138 | [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2 | |
139 | tags/v1.0.0 | |
c06818e2 | 140 | |
492cf3f7 | 141 | Note that the suffix you get if you type these commands today may be |
0a565de4 | 142 | longer than what Linus saw above when he ran these commands, as your |
2de9b711 | 143 | Git repository may have new commits whose object names begin with |
492cf3f7 GA |
144 | 975b that did not exist back then, and "-g975b" suffix alone may not |
145 | be sufficient to disambiguate these commits. | |
146 | ||
147 | ||
8713ab30 SP |
148 | SEARCH STRATEGY |
149 | --------------- | |
150 | ||
a8a5406a | 151 | For each commit-ish supplied, 'git describe' will first look for |
8713ab30 SP |
152 | a tag which tags exactly that commit. Annotated tags will always |
153 | be preferred over lightweight tags, and tags with newer dates will | |
154 | always be preferred over tags with older dates. If an exact match | |
155 | is found, its name will be output and searching will stop. | |
156 | ||
0b444cdb | 157 | If an exact match was not found, 'git describe' will walk back |
8713ab30 SP |
158 | through the commit history to locate an ancestor commit which |
159 | has been tagged. The ancestor's tag will be output along with an | |
bcf9626a | 160 | abbreviation of the input commit-ish's SHA-1. If `--first-parent` was |
e00dd1e9 MC |
161 | specified then the walk will only consider the first parent of each |
162 | commit. | |
8713ab30 SP |
163 | |
164 | If multiple tags were found during the walk then the tag which | |
a8a5406a | 165 | has the fewest commits different from the input commit-ish will be |
8713ab30 | 166 | selected and output. Here fewest commits different is defined as |
483bc4f0 | 167 | the number of commits which would be shown by `git log tag..input` |
8713ab30 SP |
168 | will be the smallest number of commits possible. |
169 | ||
c06818e2 JH |
170 | GIT |
171 | --- | |
9e1f0a85 | 172 | Part of the linkgit:git[1] suite |