This command is great for getting a concise, human-readable snapshot of where your code is at, even when there are no tags or you have uncommitted edits.
By default, it tries to find the nearest tag and describe how many commits you are past it, but with --always
it will fall back to the abbreviated commit hash if no tag is found, and --dirty
appends "-dirty" when there are local modifications in the working tree. This makes it ideal for CI logs or build metadata where you need a unique identifier that also signals uncommitted work.
You can adjust the detail level with --abbrev=<n>
to change the hash length, use --tags
to include lightweight tags, or --all
to match any ref, and you can even customize the dirty marker with --dirty=<marker>
. For simpler outputs, git rev-parse --short HEAD
gives just the short hash, while git describe --abbrev=0
returns only the most recent tag.