简体   繁体   English

如何在git中获得最新标签(一致)?

[英]How to get the latest tag in git (consistently)?

In some projects, the git describe --tags command returns the exact lastest tag name, but in other cases it returns extra information: 在某些项目中, git describe --tags命令返回确切的最新标签名称,但在其他情况下,它返回额外的信息:

project1> git describe --tags
2.0-BETA6

project2> git describe --tags
1.5-13-g4abc82e

Is there a way to call git describe so that it returns either just the first format (TAG only) or just the second format (TAG with commit info). 有没有一种方法可以调用git describe,以便它仅返回第一种格式(仅包含TAG)或仅返回第二种格式(带有提交信息的TAG)。

I am trying to update a java properies file to contain a property with the most recent tag, and another property with the most recent commit. 我正在尝试更新一个Java属性文件,使其包含具有最新标签的属性以及具有最新提交的另一个属性。

In case it matters, im using "git version 1.7.9.6 (Apple Git-31.1)" 如果有问题,我将使用“ git版本1.7.9.6(Apple Git-31.1)”

要在所有分支机构中获取最新标签:

git describe --tags `git rev-list --tags --max-count=1`

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

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