Documentation / git-describe.txton commit Merge branch 'sg/ci-libsvn-perl' (6f3d93f)
   1git-describe(1)
   2===============
   3
   4NAME
   5----
   6git-describe - Give an object a human readable name based on an available ref
   7
   8SYNOPSIS
   9--------
  10[verse]
  11'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...]
  12'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
  13'git describe' <blob>
  14
  15DESCRIPTION
  16-----------
  17The command finds the most recent tag that is reachable from a
  18commit.  If the tag points to the commit, then only the tag is
  19shown.  Otherwise, it suffixes the tag name with the number of
  20additional commits on top of the tagged object and the
  21abbreviated object name of the most recent commit. The result
  22is a "human-readable" object name which can also be used to
  23identify the commit to other git commands.
  24
  25By default (without --all or --tags) `git describe` only shows
  26annotated tags.  For more information about creating annotated tags
  27see the -a and -s options to linkgit:git-tag[1].
  28
  29If the given object refers to a blob, it will be described
  30as `<commit-ish>:<path>`, such that the blob can be found
  31at `<path>` in the `<commit-ish>`, which itself describes the
  32first commit in which this blob occurs in a reverse revision walk
  33from HEAD.
  34
  35OPTIONS
  36-------
  37<commit-ish>...::
  38        Commit-ish object names to describe.  Defaults to HEAD if omitted.
  39
  40--dirty[=<mark>]::
  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.
  49
  50--all::
  51        Instead of using only the annotated tags, use any ref
  52        found in `refs/` namespace.  This option enables matching
  53        any known branch, remote-tracking branch, or lightweight tag.
  54
  55--tags::
  56        Instead of using only the annotated tags, use any tag
  57        found in `refs/tags` namespace.  This option enables matching
  58        a lightweight (non-annotated) tag.
  59
  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
  65--abbrev=<n>::
  66        Instead of using the default 7 hexadecimal digits as the
  67        abbreviated object name, use <n> digits, or as many digits
  68        as needed to form a unique object name.  An <n> of 0
  69        will suppress long format, only showing the closest tag.
  70
  71--candidates=<n>::
  72        Instead of considering only the 10 most recent tags as
  73        candidates to describe the input commit-ish consider
  74        up to <n> candidates.  Increasing <n> above 10 will take
  75        slightly longer but may produce a more accurate result.
  76        An <n> of 0 will cause only exact matches to be output.
  77
  78--exact-match::
  79        Only output exact matches (a tag directly references the
  80        supplied commit).  This is a synonym for --candidates=0.
  81
  82--debug::
  83        Verbosely display information about the searching strategy
  84        being employed to standard error.  The tag name will still
  85        be printed to standard out.
  86
  87--long::
  88        Always output the long format (the tag, the number of commits
  89        and the abbreviated commit name) even when it matches a tag.
  90        This is useful when you want to see parts of the commit object name
  91        in "describe" output, even when the commit in question happens to be
  92        a tagged version.  Instead of just emitting the tag name, it will
  93        describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
  94        that points at object deadbee....).
  95
  96--match <pattern>::
  97        Only consider tags matching the given `glob(7)` pattern,
  98        excluding the "refs/tags/" prefix. If used with `--all`, it also
  99        considers local branches and remote-tracking references matching the
 100        pattern, excluding respectively "refs/heads/" and "refs/remotes/"
 101        prefix; references of other types are never considered. If given
 102        multiple times, a list of patterns will be accumulated, and tags
 103        matching any of the patterns will be considered.  Use `--no-match` to
 104        clear and reset the list of patterns.
 105
 106--exclude <pattern>::
 107        Do not consider tags matching the given `glob(7)` pattern, excluding
 108        the "refs/tags/" prefix. If used with `--all`, it also does not consider
 109        local branches and remote-tracking references matching the pattern,
 110        excluding respectively "refs/heads/" and "refs/remotes/" prefix;
 111        references of other types are never considered. If given multiple times,
 112        a list of patterns will be accumulated and tags matching any of the
 113        patterns will be excluded. When combined with --match a tag will be
 114        considered when it matches at least one --match pattern and does not
 115        match any of the --exclude patterns. Use `--no-exclude` to clear and
 116        reset the list of patterns.
 117
 118--always::
 119        Show uniquely abbreviated commit object as fallback.
 120
 121--first-parent::
 122        Follow only the first parent commit upon seeing a merge commit.
 123        This is useful when you wish to not match tags on branches merged
 124        in the history of the target commit.
 125
 126EXAMPLES
 127--------
 128
 129With something like git.git current tree, I get:
 130
 131        [torvalds@g5 git]$ git describe parent
 132        v1.0.4-14-g2414721
 133
 134i.e. the current head of my "parent" branch is based on v1.0.4,
 135but since it has a few commits on top of that,
 136describe has added the number of additional commits ("14") and
 137an abbreviated object name for the commit itself ("2414721")
 138at the end.
 139
 140The number of additional commits is the number
 141of commits which would be displayed by "git log v1.0.4..parent".
 142The hash suffix is "-g" + unambiguous abbreviation for the tip commit
 143of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
 144The "g" prefix stands for "git" and is used to allow describing the version of
 145a software depending on the SCM the software is managed with. This is useful
 146in an environment where people may use different SCMs.
 147
 148Doing a 'git describe' on a tag-name will just show the tag name:
 149
 150        [torvalds@g5 git]$ git describe v1.0.4
 151        v1.0.4
 152
 153With --all, the command can use branch heads as references, so
 154the output shows the reference path as well:
 155
 156        [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
 157        tags/v1.0.0-21-g975b
 158
 159        [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
 160        heads/lt/describe-7-g975b
 161
 162With --abbrev set to 0, the command can be used to find the
 163closest tagname without any suffix:
 164
 165        [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
 166        tags/v1.0.0
 167
 168Note that the suffix you get if you type these commands today may be
 169longer than what Linus saw above when he ran these commands, as your
 170Git repository may have new commits whose object names begin with
 171975b that did not exist back then, and "-g975b" suffix alone may not
 172be sufficient to disambiguate these commits.
 173
 174
 175SEARCH STRATEGY
 176---------------
 177
 178For each commit-ish supplied, 'git describe' will first look for
 179a tag which tags exactly that commit.  Annotated tags will always
 180be preferred over lightweight tags, and tags with newer dates will
 181always be preferred over tags with older dates.  If an exact match
 182is found, its name will be output and searching will stop.
 183
 184If an exact match was not found, 'git describe' will walk back
 185through the commit history to locate an ancestor commit which
 186has been tagged.  The ancestor's tag will be output along with an
 187abbreviation of the input commit-ish's SHA-1. If `--first-parent` was
 188specified then the walk will only consider the first parent of each
 189commit.
 190
 191If multiple tags were found during the walk then the tag which
 192has the fewest commits different from the input commit-ish will be
 193selected and output.  Here fewest commits different is defined as
 194the number of commits which would be shown by `git log tag..input`
 195will be the smallest number of commits possible.
 196
 197BUGS
 198----
 199
 200Tree objects as well as tag objects not pointing at commits, cannot be described.
 201When describing blobs, the lightweight tags pointing at blobs are ignored,
 202but the blob is still described as <committ-ish>:<path> despite the lightweight
 203tag being favorable.
 204
 205GIT
 206---
 207Part of the linkgit:git[1] suite