Teach git-describe to display distances from tags.
[git/git.git] / Documentation / git-describe.txt
CommitLineData
c06818e2
JH
1git-describe(1)
2===============
3
4NAME
5----
7bd7f280 6git-describe - Show the most recent tag that is reachable from a commit
c06818e2
JH
7
8
9SYNOPSIS
10--------
11'git-describe' [--all] [--tags] [--abbrev=<n>] <committish>...
12
13DESCRIPTION
14-----------
15The command finds the most recent tag that is reachable from a
16commit, and if the commit itself is pointed at by the tag, shows
17the tag. Otherwise, it suffixes the tag name with abbreviated
18object name of the commit.
19
20
21OPTIONS
22-------
23<committish>::
37425065 24 The object name of the committish.
c06818e2
JH
25
26--all::
27 Instead of using only the annotated tags, use any ref
28 found in `.git/refs/`.
29
30--tags::
31 Instead of using only the annotated tags, use any tag
32 found in `.git/refs/tags`.
33
34--abbrev=<n>::
35 Instead of using the default 8 hexadecimal digits as the
36 abbreviated object name, use <n> digits.
37
8713ab30
SP
38--candidates=<n>::
39 Instead of considering only the 10 most recent tags as
40 candidates to describe the input committish consider
41 up to <n> candidates. Increasing <n> above 10 will take
42 slightly longer but may produce a more accurate result.
43
44--debug::
45 Verbosely display information about the searching strategy
46 being employed to standard error. The tag name will still
47 be printed to standard out.
c06818e2
JH
48
49EXAMPLES
50--------
51
52With something like git.git current tree, I get:
53
54 [torvalds@g5 git]$ git-describe parent
55 v1.0.4-g2414721b
56
57i.e. the current head of my "parent" branch is based on v1.0.4,
58but since it has a few commits on top of that, it has added the
59git hash of the thing to the end: "-g" + 8-char shorthand for
60the commit `2414721b194453f058079d897d13c4e377f92dc6`.
61
62Doing a "git-describe" on a tag-name will just show the tag name:
63
64 [torvalds@g5 git]$ git-describe v1.0.4
65 v1.0.4
66
67With --all, the command can use branch heads as references, so
68the output shows the reference path as well:
69
70 [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
71 tags/v1.0.0-g975b
72
73 [torvalds@g5 git]$ git describe --all HEAD^
74 heads/lt/describe-g975b
75
8713ab30
SP
76SEARCH STRATEGY
77---------------
78
79For each committish supplied "git describe" will first look for
80a tag which tags exactly that commit. Annotated tags will always
81be preferred over lightweight tags, and tags with newer dates will
82always be preferred over tags with older dates. If an exact match
83is found, its name will be output and searching will stop.
84
85If an exact match was not found "git describe" will walk back
86through the commit history to locate an ancestor commit which
87has been tagged. The ancestor's tag will be output along with an
88abbreviation of the input committish's SHA1.
89
90If multiple tags were found during the walk then the tag which
91has the fewest commits different from the input committish will be
92selected and output. Here fewest commits different is defined as
93the number of commits which would be shown by "git log tag..input"
94will be the smallest number of commits possible.
95
c06818e2
JH
96
97Author
98------
99Written by Linus Torvalds <torvalds@osdl.org>, but somewhat
100butchered by Junio C Hamano <junkio@cox.net>
101
102Documentation
103--------------
104Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
105
106GIT
107---
108Part of the gitlink:git[7] suite
109