[英]Git: How can I get the second latest version in date ? (when declined suffixed tags are made)
I am using git describe --tags
to get the latest version of my project. 我正在使用
git describe --tags
获得我项目的最新版本。
I want to get the version before that one. 我想获得那个之前的版本。
We run a script on each tag that will create many release followed with a -suffix
. 我们在每个标记上运行一个脚本,该脚本将创建许多发行版,其后跟一个
-suffix
。 git describe --tags
work because we cut that suffix. git describe --tags
有效,因为我们削减了后缀。
How can I get the version released before ? 如何获得以前发布的版本?
List of released version (ascending released by date): 发布版本列表(按日期升序排列):
v1.0.0
v1.0.0-cli
v1.0.7
v1.0.7-cli
v1.0.8
v1.0.8-cli
v1.1.0
v1.1.0-cli
v1.1.0-cli
is the latest tag, so we get the latest v1.1.0
that way, now the version before this one (in date) is v1.0.8
, how do we get it? v1.1.0-cli
是最新的标签,因此我们以这种方式获得了最新的v1.1.0
,现在(该日期之前)的版本是v1.0.8
,我们如何得到它?
As long as your current checkout is a "plain" tag (a tag without a -cli
suffix), you can get the previous tag via git describe --tags --exclude '*-*' --abbrev=0 HEAD^
. 只要您当前的结帐是“普通”标签(没有
-cli
后缀的标签),您就可以通过git describe --tags --exclude '*-*' --abbrev=0 HEAD^
获得前一个标签。
--exclude '*-*'
removes all tags with a dash within them, --exclude '*-*'
删除其中所有带有破折号的标签, --abbrev=0
suppresses the suffix --abbrev=0
禁止后缀 HEAD^
means describe the first parent of the current checked out commit HEAD^
表示描述当前已检出提交的第一父级
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.