Describe the current commit based on the nearest tag
git describe
Describe a specific commit
git describe 2414721
Use annotated and lightweight tags
git describe --tags
Use any ref (branches, remotes, tags)
git describe --all
Find the tag that contains the commit (forward search)
git describe --contains 2414721
Control the length of the hash (default is 7)
git describe --abbrev=10
Use only tags matching a glob pattern
git describe --match "v1.0.*"
Show only if the commit exactly matches a tag
git describe --exact-match HEAD
Always show full output (tag + count + hash) even if exact match
git describe --long
Append -dirty if the working tree has local changes
git describe --dirty
Allow describing a commit even if object is broken
git describe --broken
Fallback to hash if no tags found
git describe --always
Name a commit with nearest tag.
git describe --tags