Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 1 | git-describe(1) |
| 2 | =============== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Stefan Beller | 644eb60 | 2017-11-15 18:00:39 -0800 | [diff] [blame] | 6 | git-describe - Give an object a human readable name based on an available ref |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
Junio C Hamano | c5b3e0f | 2009-11-10 14:06:41 -0800 | [diff] [blame] | 10 | [verse] |
SZEDER Gábor | 2bd0706 | 2015-08-24 18:15:18 +0200 | [diff] [blame] | 11 | 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...] |
Jean Privat | 9f67d2e | 2009-10-21 09:35:22 -0400 | [diff] [blame] | 12 | 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>] |
Stefan Beller | 644eb60 | 2017-11-15 18:00:39 -0800 | [diff] [blame] | 13 | 'git describe' <blob> |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 14 | |
| 15 | DESCRIPTION |
| 16 | ----------- |
| 17 | The command finds the most recent tag that is reachable from a |
Ian Hilt | b7893cd | 2008-05-14 14:30:55 -0400 | [diff] [blame] | 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 |
Frederick Eaton | 55f6bce | 2018-09-19 13:12:31 -0700 | [diff] [blame] | 21 | abbreviated object name of the most recent commit. The result |
| 22 | is a "human-readable" object name which can also be used to |
| 23 | identify the commit to other git commands. |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 24 | |
Shawn O. Pearce | 7e425c4 | 2008-10-13 07:39:46 -0700 | [diff] [blame] | 25 | By default (without --all or --tags) `git describe` only shows |
| 26 | annotated tags. For more information about creating annotated tags |
| 27 | see the -a and -s options to linkgit:git-tag[1]. |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 28 | |
Stefan Beller | 644eb60 | 2017-11-15 18:00:39 -0800 | [diff] [blame] | 29 | If the given object refers to a blob, it will be described |
| 30 | as `<commit-ish>:<path>`, such that the blob can be found |
| 31 | at `<path>` in the `<commit-ish>`, which itself describes the |
| 32 | first commit in which this blob occurs in a reverse revision walk |
| 33 | from HEAD. |
| 34 | |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 35 | OPTIONS |
| 36 | ------- |
Richard Hansen | a8a5406 | 2013-09-04 15:04:31 -0400 | [diff] [blame] | 37 | <commit-ish>...:: |
SZEDER Gábor | 2bd0706 | 2015-08-24 18:15:18 +0200 | [diff] [blame] | 38 | Commit-ish object names to describe. Defaults to HEAD if omitted. |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 39 | |
Jean Privat | 9f67d2e | 2009-10-21 09:35:22 -0400 | [diff] [blame] | 40 | --dirty[=<mark>]:: |
Stefan Beller | b0176ce | 2017-03-21 15:57:18 -0700 | [diff] [blame] | 41 | --broken[=<mark>]:: |
| 42 | Describe the state of the working tree. When the working |
| 43 | tree matches HEAD, the output is the same as "git describe |
| 44 | HEAD". If the working tree has local modification "-dirty" |
| 45 | is appended to it. If a repository is corrupt and Git |
| 46 | cannot determine if there is local modification, Git will |
| 47 | error out, unless `--broken' is given, which appends |
| 48 | the suffix "-broken" instead. |
Jean Privat | 9f67d2e | 2009-10-21 09:35:22 -0400 | [diff] [blame] | 49 | |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 50 | --all:: |
| 51 | Instead of using only the annotated tags, use any ref |
Junio C Hamano | 831e61f | 2012-08-06 13:36:47 -0700 | [diff] [blame] | 52 | found in `refs/` namespace. This option enables matching |
Matthieu Moy | 29b9a66 | 2010-11-02 16:31:24 +0100 | [diff] [blame] | 53 | any known branch, remote-tracking branch, or lightweight tag. |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 54 | |
| 55 | --tags:: |
| 56 | Instead of using only the annotated tags, use any tag |
Junio C Hamano | 831e61f | 2012-08-06 13:36:47 -0700 | [diff] [blame] | 57 | found in `refs/tags` namespace. This option enables matching |
Shawn O. Pearce | 7e425c4 | 2008-10-13 07:39:46 -0700 | [diff] [blame] | 58 | a lightweight (non-annotated) tag. |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 59 | |
Shawn O. Pearce | 2361570 | 2007-05-21 03:20:25 -0400 | [diff] [blame] | 60 | --contains:: |
| 61 | Instead of finding the tag that predates the commit, find |
| 62 | the tag that comes after the commit, and thus contains it. |
| 63 | Automatically implies --tags. |
| 64 | |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 65 | --abbrev=<n>:: |
Anders Höckersten | bfe35a6 | 2021-05-17 05:53:50 +0000 | [diff] [blame] | 66 | Instead of using the default number of hexadecimal digits (which |
| 67 | will vary according to the number of objects in the repository with |
| 68 | a default of 7) of the abbreviated object name, use <n> digits, or |
| 69 | as many digits as needed to form a unique object name. An <n> of 0 |
Gisle Aas | 492cf3f | 2009-10-29 22:29:35 +0100 | [diff] [blame] | 70 | will suppress long format, only showing the closest tag. |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 71 | |
Shawn O. Pearce | 8713ab3 | 2007-01-13 17:30:53 -0500 | [diff] [blame] | 72 | --candidates=<n>:: |
| 73 | Instead of considering only the 10 most recent tags as |
Richard Hansen | a8a5406 | 2013-09-04 15:04:31 -0400 | [diff] [blame] | 74 | candidates to describe the input commit-ish consider |
Shawn O. Pearce | 8713ab3 | 2007-01-13 17:30:53 -0500 | [diff] [blame] | 75 | up to <n> candidates. Increasing <n> above 10 will take |
| 76 | slightly longer but may produce a more accurate result. |
Shawn O. Pearce | 2c33f75 | 2008-02-24 03:07:31 -0500 | [diff] [blame] | 77 | An <n> of 0 will cause only exact matches to be output. |
| 78 | |
| 79 | --exact-match:: |
| 80 | Only output exact matches (a tag directly references the |
| 81 | supplied commit). This is a synonym for --candidates=0. |
Shawn O. Pearce | 8713ab3 | 2007-01-13 17:30:53 -0500 | [diff] [blame] | 82 | |
| 83 | --debug:: |
| 84 | Verbosely display information about the searching strategy |
| 85 | being employed to standard error. The tag name will still |
| 86 | be printed to standard out. |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 87 | |
Santi Béjar | 518120e | 2008-02-25 10:43:33 +0100 | [diff] [blame] | 88 | --long:: |
| 89 | Always output the long format (the tag, the number of commits |
| 90 | and the abbreviated commit name) even when it matches a tag. |
| 91 | This is useful when you want to see parts of the commit object name |
| 92 | in "describe" output, even when the commit in question happens to be |
| 93 | a tagged version. Instead of just emitting the tag name, it will |
Gisle Aas | 492cf3f | 2009-10-29 22:29:35 +0100 | [diff] [blame] | 94 | describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2 |
| 95 | that points at object deadbee....). |
Santi Béjar | 518120e | 2008-02-25 10:43:33 +0100 | [diff] [blame] | 96 | |
Pierre Habouzit | 30ffa60 | 2007-12-21 22:49:54 +0100 | [diff] [blame] | 97 | --match <pattern>:: |
Greg Price | 5229149 | 2013-02-25 00:29:01 -0500 | [diff] [blame] | 98 | Only consider tags matching the given `glob(7)` pattern, |
Max Kirillov | 6d68b2a | 2017-09-20 04:10:10 +0300 | [diff] [blame] | 99 | excluding the "refs/tags/" prefix. If used with `--all`, it also |
| 100 | considers local branches and remote-tracking references matching the |
| 101 | pattern, excluding respectively "refs/heads/" and "refs/remotes/" |
| 102 | prefix; references of other types are never considered. If given |
| 103 | multiple times, a list of patterns will be accumulated, and tags |
| 104 | matching any of the patterns will be considered. Use `--no-match` to |
| 105 | clear and reset the list of patterns. |
Pierre Habouzit | 30ffa60 | 2007-12-21 22:49:54 +0100 | [diff] [blame] | 106 | |
Jacob Keller | 77d21f2 | 2017-01-18 15:06:08 -0800 | [diff] [blame] | 107 | --exclude <pattern>:: |
| 108 | Do not consider tags matching the given `glob(7)` pattern, excluding |
Max Kirillov | 6d68b2a | 2017-09-20 04:10:10 +0300 | [diff] [blame] | 109 | the "refs/tags/" prefix. If used with `--all`, it also does not consider |
| 110 | local branches and remote-tracking references matching the pattern, |
| 111 | excluding respectively "refs/heads/" and "refs/remotes/" prefix; |
| 112 | references of other types are never considered. If given multiple times, |
| 113 | a list of patterns will be accumulated and tags matching any of the |
| 114 | patterns will be excluded. When combined with --match a tag will be |
| 115 | considered when it matches at least one --match pattern and does not |
Jacob Keller | 77d21f2 | 2017-01-18 15:06:08 -0800 | [diff] [blame] | 116 | match any of the --exclude patterns. Use `--no-exclude` to clear and |
| 117 | reset the list of patterns. |
| 118 | |
Stephan Beyer | a3800f6 | 2008-06-08 03:36:11 +0200 | [diff] [blame] | 119 | --always:: |
| 120 | Show uniquely abbreviated commit object as fallback. |
| 121 | |
Mike Crowe | e00dd1e | 2013-05-17 21:56:18 +0100 | [diff] [blame] | 122 | --first-parent:: |
| 123 | Follow only the first parent commit upon seeing a merge commit. |
| 124 | This is useful when you wish to not match tags on branches merged |
| 125 | in the history of the target commit. |
| 126 | |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 127 | EXAMPLES |
| 128 | -------- |
| 129 | |
| 130 | With something like git.git current tree, I get: |
| 131 | |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 132 | [torvalds@g5 git]$ git describe parent |
Junio C Hamano | 1891261 | 2007-01-26 23:24:07 -0800 | [diff] [blame] | 133 | v1.0.4-14-g2414721 |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 134 | |
| 135 | i.e. the current head of my "parent" branch is based on v1.0.4, |
Jon Loeliger | 323b9db | 2009-01-12 14:02:07 -0600 | [diff] [blame] | 136 | but since it has a few commits on top of that, |
Junio C Hamano | 1891261 | 2007-01-26 23:24:07 -0800 | [diff] [blame] | 137 | describe has added the number of additional commits ("14") and |
| 138 | an abbreviated object name for the commit itself ("2414721") |
| 139 | at the end. |
| 140 | |
| 141 | The number of additional commits is the number |
| 142 | of commits which would be displayed by "git log v1.0.4..parent". |
Linus Arver | 548afb0 | 2023-06-07 19:26:47 +0000 | [diff] [blame] | 143 | The hash suffix is "-g" + an unambiguous abbreviation for the tip commit |
Anders Höckersten | bfe35a6 | 2021-05-17 05:53:50 +0000 | [diff] [blame] | 144 | of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`). The |
| 145 | length of the abbreviation scales as the repository grows, using the |
| 146 | approximate number of objects in the repository and a bit of math |
| 147 | around the birthday paradox, and defaults to a minimum of 7. |
Markus Heidelberg | 846b8f6 | 2010-03-22 21:45:33 +0100 | [diff] [blame] | 148 | The "g" prefix stands for "git" and is used to allow describing the version of |
| 149 | a software depending on the SCM the software is managed with. This is useful |
| 150 | in an environment where people may use different SCMs. |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 151 | |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 152 | Doing a 'git describe' on a tag-name will just show the tag name: |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 153 | |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 154 | [torvalds@g5 git]$ git describe v1.0.4 |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 155 | v1.0.4 |
| 156 | |
| 157 | With --all, the command can use branch heads as references, so |
| 158 | the output shows the reference path as well: |
| 159 | |
| 160 | [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2 |
Junio C Hamano | 1891261 | 2007-01-26 23:24:07 -0800 | [diff] [blame] | 161 | tags/v1.0.0-21-g975b |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 162 | |
Gisle Aas | 492cf3f | 2009-10-29 22:29:35 +0100 | [diff] [blame] | 163 | [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^ |
Junio C Hamano | 1891261 | 2007-01-26 23:24:07 -0800 | [diff] [blame] | 164 | heads/lt/describe-7-g975b |
| 165 | |
| 166 | With --abbrev set to 0, the command can be used to find the |
| 167 | closest tagname without any suffix: |
| 168 | |
| 169 | [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2 |
| 170 | tags/v1.0.0 |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 171 | |
Gisle Aas | 492cf3f | 2009-10-29 22:29:35 +0100 | [diff] [blame] | 172 | Note that the suffix you get if you type these commands today may be |
Gisle Aas | 0a565de | 2009-11-04 22:57:46 +0100 | [diff] [blame] | 173 | longer than what Linus saw above when he ran these commands, as your |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 174 | Git repository may have new commits whose object names begin with |
Gisle Aas | 492cf3f | 2009-10-29 22:29:35 +0100 | [diff] [blame] | 175 | 975b that did not exist back then, and "-g975b" suffix alone may not |
| 176 | be sufficient to disambiguate these commits. |
| 177 | |
| 178 | |
Shawn O. Pearce | 8713ab3 | 2007-01-13 17:30:53 -0500 | [diff] [blame] | 179 | SEARCH STRATEGY |
| 180 | --------------- |
| 181 | |
Richard Hansen | a8a5406 | 2013-09-04 15:04:31 -0400 | [diff] [blame] | 182 | For each commit-ish supplied, 'git describe' will first look for |
Shawn O. Pearce | 8713ab3 | 2007-01-13 17:30:53 -0500 | [diff] [blame] | 183 | a tag which tags exactly that commit. Annotated tags will always |
| 184 | be preferred over lightweight tags, and tags with newer dates will |
| 185 | always be preferred over tags with older dates. If an exact match |
| 186 | is found, its name will be output and searching will stop. |
| 187 | |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 188 | If an exact match was not found, 'git describe' will walk back |
Shawn O. Pearce | 8713ab3 | 2007-01-13 17:30:53 -0500 | [diff] [blame] | 189 | through the commit history to locate an ancestor commit which |
| 190 | has been tagged. The ancestor's tag will be output along with an |
Matthieu Moy | bcf9626 | 2016-06-28 13:40:11 +0200 | [diff] [blame] | 191 | abbreviation of the input commit-ish's SHA-1. If `--first-parent` was |
Mike Crowe | e00dd1e | 2013-05-17 21:56:18 +0100 | [diff] [blame] | 192 | specified then the walk will only consider the first parent of each |
| 193 | commit. |
Shawn O. Pearce | 8713ab3 | 2007-01-13 17:30:53 -0500 | [diff] [blame] | 194 | |
| 195 | If multiple tags were found during the walk then the tag which |
Richard Hansen | a8a5406 | 2013-09-04 15:04:31 -0400 | [diff] [blame] | 196 | has the fewest commits different from the input commit-ish will be |
Shawn O. Pearce | 8713ab3 | 2007-01-13 17:30:53 -0500 | [diff] [blame] | 197 | selected and output. Here fewest commits different is defined as |
Jonathan Nieder | 483bc4f | 2008-06-30 13:56:34 -0500 | [diff] [blame] | 198 | the number of commits which would be shown by `git log tag..input` |
Shawn O. Pearce | 8713ab3 | 2007-01-13 17:30:53 -0500 | [diff] [blame] | 199 | will be the smallest number of commits possible. |
| 200 | |
Stefan Beller | 644eb60 | 2017-11-15 18:00:39 -0800 | [diff] [blame] | 201 | BUGS |
| 202 | ---- |
| 203 | |
| 204 | Tree objects as well as tag objects not pointing at commits, cannot be described. |
| 205 | When describing blobs, the lightweight tags pointing at blobs are ignored, |
Linus Arver | 548afb0 | 2023-06-07 19:26:47 +0000 | [diff] [blame] | 206 | but the blob is still described as <commit-ish>:<path> despite the lightweight |
Stefan Beller | 644eb60 | 2017-11-15 18:00:39 -0800 | [diff] [blame] | 207 | tag being favorable. |
| 208 | |
Junio C Hamano | c06818e | 2005-12-27 16:10:56 -0800 | [diff] [blame] | 209 | GIT |
| 210 | --- |
Christian Couder | 9e1f0a8 | 2008-06-06 09:07:32 +0200 | [diff] [blame] | 211 | Part of the linkgit:git[1] suite |