git describe
git
Usage
git describe [--tags] [--dirty]Names the current commit from the nearest tag, as v1.2.0-5-gabc1234; it only sees annotated tags by default, so lightweight ones need --tags and a repository with no tag needs --always.
Common flags
| Flag | Meaning |
|---|---|
| --tags | use lightweight tags too, not just annotated ones |
| --dirty | append -dirty when the working tree has changes |
| --always | fall back to a bare hash when no tag is found |
| --long | always the full tag-count-hash form |
| --abbrev=<n> | how many hash digits to print |
| --match <pattern> | only consider matching tags |
Examples
git describe --tags --dirtyprints something like v1.2.0-5-gabc1234-dirty
git describe --alwaysnever fails, even in a repository with no tags
git describe --match "v*" --longignores tags that are not versions
The confusion is that undo has several shapes — moving where a branch points is not the same as adding a commit that reverses it.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does git describe do?
Names the current commit from the nearest tag, as v1.2.0-5-gabc1234; it only sees annotated tags by default, so lightweight ones need --tags and a repository with no tag needs --always.
Q. How do I type it?
git describe [--tags] [--dirty] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
6 are listed here; the full set is in man git. This command sits under git.
Related commands
man page: man git-describe