Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 1 | git-describe(1) |
| 2 | =============== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 0107892 | 2006-03-10 00:31:47 | [diff] [blame] | 6 | git-describe - Show the most recent tag that is reachable from a commit |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Junio C Hamano | 0ecfa0f | 2009-11-10 22:13:24 | [diff] [blame] | 11 | [verse] |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 12 | 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] <committish>... |
Junio C Hamano | 446ed77 | 2009-11-10 22:02:20 | [diff] [blame] | 13 | 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>] |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 14 | |
| 15 | DESCRIPTION |
| 16 | ----------- |
| 17 | The command finds the most recent tag that is reachable from a |
Junio C Hamano | 2fbcd21 | 2008-05-14 22:26:07 | [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 |
| 21 | abbreviated object name of the most recent commit. |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 22 | |
Junio C Hamano | 7d06a8a | 2008-10-20 05:42:33 | [diff] [blame] | 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]. |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 26 | |
| 27 | OPTIONS |
| 28 | ------- |
Junio C Hamano | 9e39507 | 2008-07-31 22:11:21 | [diff] [blame] | 29 | <committish>...:: |
| 30 | Committish object names to describe. |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 31 | |
Junio C Hamano | 446ed77 | 2009-11-10 22:02:20 | [diff] [blame] | 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 | |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 37 | --all:: |
| 38 | Instead of using only the annotated tags, use any ref |
Junio C Hamano | 7d06a8a | 2008-10-20 05:42:33 | [diff] [blame] | 39 | found in `.git/refs/`. This option enables matching |
| 40 | any known branch, remote branch, or lightweight tag. |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 41 | |
| 42 | --tags:: |
| 43 | Instead of using only the annotated tags, use any tag |
Junio C Hamano | 7d06a8a | 2008-10-20 05:42:33 | [diff] [blame] | 44 | found in `.git/refs/tags`. This option enables matching |
| 45 | a lightweight (non-annotated) tag. |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 46 | |
Junio C Hamano | 5e284b4 | 2007-05-22 07:23:37 | [diff] [blame] | 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 | |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 52 | --abbrev=<n>:: |
Junio C Hamano | 22bcc11 | 2009-01-24 08:05:18 | [diff] [blame] | 53 | Instead of using the default 7 hexadecimal digits as the |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 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. |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 57 | |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 58 | --candidates=<n>:: |
| 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. |
Junio C Hamano | 24bc09a | 2008-02-28 00:27:44 | [diff] [blame] | 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. |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 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. |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 73 | |
Junio C Hamano | 4f1d8c4 | 2008-03-03 02:01:16 | [diff] [blame] | 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 |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 80 | describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2 |
| 81 | that points at object deadbee....). |
Junio C Hamano | 4f1d8c4 | 2008-03-03 02:01:16 | [diff] [blame] | 82 | |
Junio C Hamano | 9c33415 | 2008-02-12 03:18:52 | [diff] [blame] | 83 | --match <pattern>:: |
| 84 | Only consider tags matching the given pattern (can be used to avoid |
| 85 | leaking private tags made from the repository). |
| 86 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 87 | --always:: |
| 88 | Show uniquely abbreviated commit object as fallback. |
| 89 | |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 90 | EXAMPLES |
| 91 | -------- |
| 92 | |
| 93 | With something like git.git current tree, I get: |
| 94 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 95 | [torvalds@g5 git]$ git describe parent |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 96 | v1.0.4-14-g2414721 |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 97 | |
| 98 | i.e. the current head of my "parent" branch is based on v1.0.4, |
Junio C Hamano | 6efe302 | 2009-01-13 16:47:56 | [diff] [blame] | 99 | but since it has a few commits on top of that, |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 100 | describe has added the number of additional commits ("14") and |
| 101 | an abbreviated object name for the commit itself ("2414721") |
| 102 | at the end. |
| 103 | |
| 104 | The number of additional commits is the number |
| 105 | of commits which would be displayed by "git log v1.0.4..parent". |
| 106 | The hash suffix is "-g" + 7-char abbreviation for the tip commit |
| 107 | of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`). |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 108 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 109 | Doing a 'git-describe' on a tag-name will just show the tag name: |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 110 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 111 | [torvalds@g5 git]$ git describe v1.0.4 |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 112 | v1.0.4 |
| 113 | |
| 114 | With --all, the command can use branch heads as references, so |
| 115 | the output shows the reference path as well: |
| 116 | |
| 117 | [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2 |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 118 | tags/v1.0.0-21-g975b |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 119 | |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 120 | [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^ |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 121 | heads/lt/describe-7-g975b |
| 122 | |
| 123 | With --abbrev set to 0, the command can be used to find the |
| 124 | closest tagname without any suffix: |
| 125 | |
| 126 | [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2 |
| 127 | tags/v1.0.0 |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 128 | |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 129 | Note that the suffix you get if you type these commands today may be |
Junio C Hamano | a1f8633 | 2009-11-05 05:28:43 | [diff] [blame] | 130 | longer than what Linus saw above when he ran these commands, as your |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 131 | git repository may have new commits whose object names begin with |
| 132 | 975b that did not exist back then, and "-g975b" suffix alone may not |
| 133 | be sufficient to disambiguate these commits. |
| 134 | |
| 135 | |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 136 | SEARCH STRATEGY |
| 137 | --------------- |
| 138 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 139 | For each committish supplied, 'git-describe' will first look for |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 140 | a tag which tags exactly that commit. Annotated tags will always |
| 141 | be preferred over lightweight tags, and tags with newer dates will |
| 142 | always be preferred over tags with older dates. If an exact match |
| 143 | is found, its name will be output and searching will stop. |
| 144 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 145 | If an exact match was not found, 'git-describe' will walk back |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 146 | through the commit history to locate an ancestor commit which |
| 147 | has been tagged. The ancestor's tag will be output along with an |
| 148 | abbreviation of the input committish's SHA1. |
| 149 | |
| 150 | If multiple tags were found during the walk then the tag which |
| 151 | has the fewest commits different from the input committish will be |
| 152 | selected and output. Here fewest commits different is defined as |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 153 | the number of commits which would be shown by `git log tag..input` |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 154 | will be the smallest number of commits possible. |
| 155 | |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 156 | |
| 157 | Author |
| 158 | ------ |
| 159 | Written by Linus Torvalds <torvalds@osdl.org>, but somewhat |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 160 | butchered by Junio C Hamano <gitster@pobox.com>. Later significantly |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 161 | updated by Shawn Pearce <spearce@spearce.org>. |
Junio C Hamano | ab00876 | 2005-12-28 02:33:00 | [diff] [blame] | 162 | |
| 163 | Documentation |
| 164 | -------------- |
| 165 | Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>. |
| 166 | |
| 167 | GIT |
| 168 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 169 | Part of the linkgit:git[1] suite |