[英]How to get latest tag name not using `git fetch --tags`
There has been an answer said how to get a latest tag, https://stackoverflow.com/a/7979255/7909869 .有一个答案说如何获取最新标签, https://stackoverflow.com/a/7979255/7909869 。 But the premise is we must use
git fetch --tags
first after I use git clone REPO --depth=1
.但前提是我们必须在使用
git clone REPO --depth=1
之后先使用git fetch --tags
。 My REPO has many tags that means git fetch --tags
will take a lot of time to download tags, and my request here is just to get the latest tag name not the whole code.我的 REPO 有很多标签,这意味着
git fetch --tags
将花费大量时间来下载标签,我在这里的请求只是获取最新的标签名称而不是整个代码。
You could take a look at git describe
:你可以看看
git describe
:
git describe --abbrev=0
it should return closest annotated tag git describe --abbrev=0
它应该返回最接近的带注释的标签
or to get the latest annotated tag which targets only the current commit in the current branch, use或者要获取仅针对当前分支中的当前提交的最新注释标签,请使用
git describe --exact-match --abbrev=0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.