简体   繁体   English

获取当前分支上带有最新标签的提交哈希

[英]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.我确实获得了所有标签及其提交 ID,但我只需要最新的标签和哈希值本身。

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.但它仍然是一个完整的列表,我只需要最后一个 id。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM