git-describe - Linux


git-describe generates a human-readable description of the current commit in a Git repository. It is designed for describing commits in a user-friendly and informative way, making it useful for error messages, release notes, and more.


git describe [options]


  • -a: All commits are listed in sequence, with the most recent commit listed first.
  • -l: Instead of listing only the first tag, list a longer series of tags.
  • -tags: Search backwards to find the last tag.
  • -abbrev=<n>: Abbreviate the commit SHA1 hash to the specified number of characters. Default: 7.
  • -dirty: If the working directory is dirty, include the suffix -dirty.
  • -always: Always include the long SHA1 hash in the description.
  • -debug: Print debugging information.


  • Get a short commit description with the latest tag:
    git describe
  • Get a longer commit description with the last 5 tags:
    git describe -l5
  • Include the full SHA1 hash in the description:
    git describe --always
  • Abbreviate the SHA1 hash to 10 characters:
    git describe --abbrev=10

Common Issues

  • No tags found: If no tags are found in the repository, git-describe will fallback to using the commit SHA1 hash.
  • Multiple tags found: If multiple tags match the current commit, git-describe will use the most recent tag.
  • Dirty working directory: If the working directory contains uncommitted changes, git-describe may include the suffix -dirty in the description.


git-describe can be used in conjunction with other Git commands for advanced tasks. For example:

  • Generate a commit message with the commit description:
    git commit -m "$(git describe)"
  • Filter log output based on git-describe:
    git log --decorate --oneline | grep "$(git describe --abbrev)"

Related Commands

  • git-tag
  • git-rev-parse
  • git-commit