开发者

How to get latest tag name? [duplicate]

开发者 https://www.devze.com 2023-01-26 18:03 出处:网络
This question already has answers here: How can I get the latest tag name in current branch in Git? 开发者_如何学Python(25 answers)
This question already has answers here: How can I get the latest tag name in current branch in Git? 开发者_如何学Python (25 answers) Closed 7 years ago.

How to get latest tag name (like version) of current branch?


git describe should be enough

The command finds the most recent tag that is reachable from a commit.
If the tag points to the commit, then only the tag is shown.
Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit.

With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:

[torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
tags/v1.0.0

For tags matching a certain pattern:

git describe --tags --abbrev=0 --match release-*

(Peterino's comment)

For the latest tag on all the branches (not just the latest branch)

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

(from kilianc's answer)

0

精彩评论

暂无评论...
验证码 换一张
取 消