user3142695
user3142695

Reputation: 17352

Get hash of commit with latest tag on current branch

I need to get the hash of the latest tag commit on the current branch.

If I do

git show-ref --tag

I do get all tags and their commit ids, but I just need the latest one and only the hash itself.

Doing

git describe --tags --abbrev=0

Only gives me the latest tag, but no hash...

So I did

git tag --list --format '%(refname:short) %(objectname:short)'

But still it is a complete list and I only need the last id.

Upvotes: 0

Views: 593

Answers (1)

zrrbite
zrrbite

Reputation: 1260

$ git describe --tags --abbrev=0 | xargs git rev-parse

Upvotes: 2

Related Questions