Documentation / git-describe.txton commit builtin/pull: convert to struct object_id (f9b1114)
   1git-describe(1)
   2===============
   3
   4NAME
   5----
   6git-describe - Describe a commit using the most recent tag reachable from it
   7
   8
   9SYNOPSIS
  10--------
  11[verse]
  12'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...]
  13'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
  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.
  22
  23By default (without --all or --tags) `git describe` only shows
  24annotated tags.  For more information about creating annotated tags
  25see the -a and -s options to linkgit:git-tag[1].
  26
  27OPTIONS
  28-------
  29<commit-ish>...::
  30        Commit-ish object names to describe.  Defaults to HEAD if omitted.
  31
  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
  37--all::
  38        Instead of using only the annotated tags, use any ref
  39        found in `refs/` namespace.  This option enables matching
  40        any known branch, remote-tracking branch, or lightweight tag.
  41
  42--tags::
  43        Instead of using only the annotated tags, use any tag
  44        found in `refs/tags` namespace.  This option enables matching
  45        a lightweight (non-annotated) tag.
  46
  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
  52--abbrev=<n>::
  53        Instead of using the default 7 hexadecimal digits as the
  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.
  57
  58--candidates=<n>::
  59        Instead of considering only the 10 most recent tags as
  60        candidates to describe the input commit-ish consider
  61        up to <n> candidates.  Increasing <n> above 10 will take
  62        slightly longer but may produce a more accurate result.
  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.
  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.
  73
  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
  80        describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
  81        that points at object deadbee....).
  82
  83--match <pattern>::
  84        Only consider tags matching the given `glob(7)` pattern,
  85        excluding the "refs/tags/" prefix.  This can be used to avoid
  86        leaking private tags from the repository. If given multiple times, a
  87        list of patterns will be accumulated, and tags matching any of the
  88        patterns will be considered. Use `--no-match` to clear and reset the
  89        list of patterns.
  90
  91--exclude <pattern>::
  92        Do not consider tags matching the given `glob(7)` pattern, excluding
  93        the "refs/tags/" prefix. This can be used to narrow the tag space and
  94        find only tags matching some meaningful criteria. If given multiple
  95        times, a list of patterns will be accumulated and tags matching any
  96        of the patterns will be excluded. When combined with --match a tag will
  97        be considered when it matches at least one --match pattern and does not
  98        match any of the --exclude patterns. Use `--no-exclude` to clear and
  99        reset the list of patterns.
 100
 101--always::
 102        Show uniquely abbreviated commit object as fallback.
 103
 104--first-parent::
 105        Follow only the first parent commit upon seeing a merge commit.
 106        This is useful when you wish to not match tags on branches merged
 107        in the history of the target commit.
 108
 109EXAMPLES
 110--------
 111
 112With something like git.git current tree, I get:
 113
 114        [torvalds@g5 git]$ git describe parent
 115        v1.0.4-14-g2414721
 116
 117i.e. the current head of my "parent" branch is based on v1.0.4,
 118but since it has a few commits on top of that,
 119describe has added the number of additional commits ("14") and
 120an abbreviated object name for the commit itself ("2414721")
 121at the end.
 122
 123The number of additional commits is the number
 124of commits which would be displayed by "git log v1.0.4..parent".
 125The hash suffix is "-g" + 7-char abbreviation for the tip commit
 126of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
 127The "g" prefix stands for "git" and is used to allow describing the version of
 128a software depending on the SCM the software is managed with. This is useful
 129in an environment where people may use different SCMs.
 130
 131Doing a 'git describe' on a tag-name will just show the tag name:
 132
 133        [torvalds@g5 git]$ git describe v1.0.4
 134        v1.0.4
 135
 136With --all, the command can use branch heads as references, so
 137the output shows the reference path as well:
 138
 139        [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
 140        tags/v1.0.0-21-g975b
 141
 142        [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
 143        heads/lt/describe-7-g975b
 144
 145With --abbrev set to 0, the command can be used to find the
 146closest tagname without any suffix:
 147
 148        [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
 149        tags/v1.0.0
 150
 151Note that the suffix you get if you type these commands today may be
 152longer than what Linus saw above when he ran these commands, as your
 153Git repository may have new commits whose object names begin with
 154975b that did not exist back then, and "-g975b" suffix alone may not
 155be sufficient to disambiguate these commits.
 156
 157
 158SEARCH STRATEGY
 159---------------
 160
 161For each commit-ish supplied, 'git describe' will first look for
 162a tag which tags exactly that commit.  Annotated tags will always
 163be preferred over lightweight tags, and tags with newer dates will
 164always be preferred over tags with older dates.  If an exact match
 165is found, its name will be output and searching will stop.
 166
 167If an exact match was not found, 'git describe' will walk back
 168through the commit history to locate an ancestor commit which
 169has been tagged.  The ancestor's tag will be output along with an
 170abbreviation of the input commit-ish's SHA-1. If `--first-parent` was
 171specified then the walk will only consider the first parent of each
 172commit.
 173
 174If multiple tags were found during the walk then the tag which
 175has the fewest commits different from the input commit-ish will be
 176selected and output.  Here fewest commits different is defined as
 177the number of commits which would be shown by `git log tag..input`
 178will be the smallest number of commits possible.
 179
 180GIT
 181---
 182Part of the linkgit:git[1] suite