确定最新收到的git标签 [英] Determine latest received git tag

查看:99
本文介绍了确定最新收到的git标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为我们的项目编写一个自动更新脚本。我拥有一切,但我无法确定最新收到的标签的名称。我试着用git描述,但它告诉我最新的签出标签。我当然不需要,我必须获得下一个可到达的标签才能结帐。任何想法?

解决方案

试试这个:

  git describe --tags --abbrev = 0 branch_name 

检索名称(code> HEAD (当前结账))。

也就是说,如果你的自动更新脚本获取了 origin master ,你可以这样做:

  git describe --tags --abbrev = 0 origin / master 

注意: - abbrev = 0 使 describe 只返回标签名称,最后没有sha1。 - tags 使描述返回最新的注释或未注释的标签。请参阅 git-describe(1)以获取充分讨论可能的选择。

I need to write an autoupdate script for our project. I have everything, except that I can't determine the name of the latest received tag. I tried with git describe, but it tells me the latest checked out tag. I don't need that of course, I have to get the next reachable tag to checkout. Any idea?

解决方案

Try this:

git describe --tags --abbrev=0 branch_name

to retrieve the name of the latest tag searching back from the tip of the desired branch, rather than HEAD (the current checkout).

That is, if your auto-update script has fetched origin master, you can do

git describe --tags --abbrev=0 origin/master

Note: --abbrev=0 makes describe return only the tag name, without a sha1 at the end. --tags makes describe return the latest annotated or unannotated tag. See git-describe(1) for a full discussion of the possible options.

这篇关于确定最新收到的git标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆