TheWaterProgrammer
TheWaterProgrammer

Reputation: 8219

Get the commit ID of the last tag in git history

I am on a commit which is not tagged. But there are tags in the commit history. So, following command gives me the latest release tag from the history

git describe --abbrev=0 --tags

Above outputs the tag like 1.15.21 which is good.
How can I get the commit ID that this tag was created on?

Upvotes: 0

Views: 213

Answers (1)

Cory Kramer
Cory Kramer

Reputation: 117856

You can use git rev-parse to get the commit corresponding to a branch/tag

git rev-parse HEAD
abc123......

So you can then pipe the output of your git describe using xargs

git describe --abbrev=0 --tags | xargs git rev-parse
def456.....

Upvotes: 1

Related Questions