How to get the latest tag name in current branch in Git?

To get the most recent tag (example output afterwards):

git describe --tags --abbrev=0   # 0.1.0-dev

To get the most recent tag, with the number of additional commits on top of the tagged object & more:

git describe --tags              # 0.1.0-dev-93-g1416689

To get the most recent annotated tag:

git describe --abbrev=0

You could take a look at git describe, which does something close to what you're asking.


Will output the tag of the latest tagged commit across all branches

git describe --tags $(git rev-list --tags --max-count=1)