How can I get the latest tag name in current branch in Git?

getlatest, git, git-checkout, git-tag

Solution

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

Problem

What's the simplest way to get the most recent tag in Git? ``` git tag a HEAD git tag b HEAD^^ git tag c HEAD^ git tag ``` output: ``` a b c ``` Should I write a script to get each tag's datetime and compare them?

Original source

Related problems