blob: 9f6f4831864a3112119bc7d7fec22aa7a72225e5 [file] [log] [blame]
Junio C Hamanoab008762005-12-28 02:33:001git-describe(1)
2===============
3
4NAME
5----
Junio C Hamano01078922006-03-10 00:31:476git-describe - Show the most recent tag that is reachable from a commit
Junio C Hamanoab008762005-12-28 02:33:007
8
9SYNOPSIS
10--------
Junio C Hamano5e284b42007-05-22 07:23:3711'git-describe' [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...
Junio C Hamanoab008762005-12-28 02:33:0012
13DESCRIPTION
14-----------
15The command finds the most recent tag that is reachable from a
Junio C Hamano2fbcd212008-05-14 22:26:0716commit. If the tag points to the commit, then only the tag is
17shown. Otherwise, it suffixes the tag name with the number of
18additional commits on top of the tagged object and the
19abbreviated object name of the most recent commit.
Junio C Hamanoab008762005-12-28 02:33:0020
21
22OPTIONS
23-------
24<committish>::
Junio C Hamano33db4372006-06-07 19:51:4525The object name of the committish.
Junio C Hamanoab008762005-12-28 02:33:0026
27--all::
28Instead of using only the annotated tags, use any ref
29found in `.git/refs/`.
30
31--tags::
32Instead of using only the annotated tags, use any tag
33found in `.git/refs/tags`.
34
Junio C Hamano5e284b42007-05-22 07:23:3735--contains::
36Instead of finding the tag that predates the commit, find
37the tag that comes after the commit, and thus contains it.
38Automatically implies --tags.
39
Junio C Hamanoab008762005-12-28 02:33:0040--abbrev=<n>::
41Instead of using the default 8 hexadecimal digits as the
42abbreviated object name, use <n> digits.
43
Junio C Hamanoedd2b0a2007-01-15 06:12:4544--candidates=<n>::
45Instead of considering only the 10 most recent tags as
46candidates to describe the input committish consider
47up to <n> candidates. Increasing <n> above 10 will take
48slightly longer but may produce a more accurate result.
Junio C Hamano24bc09a2008-02-28 00:27:4449An <n> of 0 will cause only exact matches to be output.
50
51--exact-match::
52Only output exact matches (a tag directly references the
53supplied commit). This is a synonym for --candidates=0.
Junio C Hamanoedd2b0a2007-01-15 06:12:4554
55--debug::
56Verbosely display information about the searching strategy
57being employed to standard error. The tag name will still
58be printed to standard out.
Junio C Hamanoab008762005-12-28 02:33:0059
Junio C Hamano4f1d8c42008-03-03 02:01:1660--long::
61Always output the long format (the tag, the number of commits
62and the abbreviated commit name) even when it matches a tag.
63This is useful when you want to see parts of the commit object name
64in "describe" output, even when the commit in question happens to be
65a tagged version. Instead of just emitting the tag name, it will
66describe such a commit as v1.2-0-deadbeef (0th commit since tag v1.2
67that points at object deadbeef....).
68
Junio C Hamano9c334152008-02-12 03:18:5269--match <pattern>::
70Only consider tags matching the given pattern (can be used to avoid
71leaking private tags made from the repository).
72
Junio C Hamanoeb415992008-06-08 22:49:4773--always::
74Show uniquely abbreviated commit object as fallback.
75
Junio C Hamanoab008762005-12-28 02:33:0076EXAMPLES
77--------
78
79With something like git.git current tree, I get:
80
81[torvalds@g5 git]$ git-describe parent
Junio C Hamanoa890c4f2007-01-28 10:29:2182v1.0.4-14-g2414721
Junio C Hamanoab008762005-12-28 02:33:0083
84i.e. the current head of my "parent" branch is based on v1.0.4,
Junio C Hamanoa890c4f2007-01-28 10:29:2185but since it has a handful commits on top of that,
86describe has added the number of additional commits ("14") and
87an abbreviated object name for the commit itself ("2414721")
88at the end.
89
90The number of additional commits is the number
91of commits which would be displayed by "git log v1.0.4..parent".
92The hash suffix is "-g" + 7-char abbreviation for the tip commit
93of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
Junio C Hamanoab008762005-12-28 02:33:0094
95Doing a "git-describe" on a tag-name will just show the tag name:
96
97[torvalds@g5 git]$ git-describe v1.0.4
98v1.0.4
99
100With --all, the command can use branch heads as references, so
101the output shows the reference path as well:
102
103[torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
Junio C Hamanoa890c4f2007-01-28 10:29:21104tags/v1.0.0-21-g975b
Junio C Hamanoab008762005-12-28 02:33:00105
106[torvalds@g5 git]$ git describe --all HEAD^
Junio C Hamanoa890c4f2007-01-28 10:29:21107heads/lt/describe-7-g975b
108
109With --abbrev set to 0, the command can be used to find the
110closest tagname without any suffix:
111
112[torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
113tags/v1.0.0
Junio C Hamanoab008762005-12-28 02:33:00114
Junio C Hamanoedd2b0a2007-01-15 06:12:45115SEARCH STRATEGY
116---------------
117
118For each committish supplied "git describe" will first look for
119a tag which tags exactly that commit. Annotated tags will always
120be preferred over lightweight tags, and tags with newer dates will
121always be preferred over tags with older dates. If an exact match
122is found, its name will be output and searching will stop.
123
124If an exact match was not found "git describe" will walk back
125through the commit history to locate an ancestor commit which
126has been tagged. The ancestor's tag will be output along with an
127abbreviation of the input committish's SHA1.
128
129If multiple tags were found during the walk then the tag which
130has the fewest commits different from the input committish will be
131selected and output. Here fewest commits different is defined as
132the number of commits which would be shown by "git log tag..input"
133will be the smallest number of commits possible.
134
Junio C Hamanoab008762005-12-28 02:33:00135
136Author
137------
138Written by Linus Torvalds <torvalds@osdl.org>, but somewhat
Junio C Hamanoa890c4f2007-01-28 10:29:21139butchered by Junio C Hamano <junkio@cox.net>. Later significantly
140updated by Shawn Pearce <spearce@spearce.org>.
Junio C Hamanoab008762005-12-28 02:33:00141
142Documentation
143--------------
144Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
145
146GIT
147---
Junio C Hamanof7c042d2008-06-06 22:50:53148Part of the linkgit:git[1] suite