如何获取远程 git 中的最新标签列表? [英] How to get list of latest tags in remote git?
问题描述
当你有本地 git repo 时,有很多方法可以获取最新的标签.
There are alot of methods to get latest tags when you have local git repo.
但我想获取远程仓库的最新标签列表.
But i want to get list of latest tags on remote repo.
我知道git ls-remote",当您使用像 x.y.z(其中 x、y、z 是数字)这样的标签时,一切都很好.但是当标签看起来像test-x.y.z"和dev-x.y.z"时,我注意到大量的test"标签会拉出任何新的dev"标签,这是不正确的.
I know about "git ls-remote", and everything is fine when you use tags like x.y.z (where x,y,z are numbers). But when tags looks like "test-x.y.z" and "dev-x.y.z" i noticed that large amount of "test" tags will pull out any new "dev" tags, which is not correct.
那么,你想如何解决这个问题?
So, how would you like solve this?
推荐答案
在 Git 2.18(2018 年第二季度)中,git ls-remote
学习了一个选项,允许根据显示的引用名对其输出进行排序.
With Git 2.18 (Q2 2018), git ls-remote
learned an option to allow sorting its output based on the refnames being shown.
请参阅 提交 1fb20df(2018 年 4 月 9 日)://github.com/HaraldNordgren" rel="nofollow noreferrer">Harald Nordgren (HaraldNordgren
).
(由 Junio C Hamano 合并 -- gitster
-- in
See commit 1fb20df (09 Apr 2018) by Harald Nordgren (HaraldNordgren
).
(Merged by Junio C Hamano -- gitster
-- in commit 6c0110f, 08 May 2018)
根据 for-each-ref
中的选项为 ls-remote
创建一个--sort
"选项.
这例如允许 ref 名称按版本语义排序,以便 v1.2
排在 v1.10
之前.
ls-remote
: create '--sort
' optionCreate a '
--sort
' option forls-remote
, based on the one fromfor-each-ref
.
This e.g. allows ref names to be sorted by version semantics, so thatv1.2
is sorted beforev1.10
.
因此请查看 Git 2.0 和 2.8 中引入的那些 for-each-ref --sort
选项,因为它们现在适用于 git ls-remote --sort
.
So check out those for-each-ref --sort
options introduced in Git 2.0 and 2.8, because they apply now to git ls-remote --sort
.
这篇关于如何获取远程 git 中的最新标签列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!