在远程git存储库上查找标记的分支

在远程git存储库上查找标记的分支,git,tags,branch,Git,Tags,Branch,我正在尝试使用gui自动化构建步骤,并希望创建一个json文件,其中包含所有可用的标记和分支头供选择。 我已经可以使用 git ls-remote --tags/heads url-of-repo 现在我想知道,哪个标签属于一个分支。 我可以做类似的事情 git branch --contains tags/<tag> git分支--包含标记/ 但我不想为了获取这些信息而在本地签出所有存储库。 也许有一个命令可以直接显示分支的所有标记?制作一个克隆,一个裸克隆 git clon

我正在尝试使用gui自动化构建步骤,并希望创建一个json文件,其中包含所有可用的标记和分支头供选择。 我已经可以使用

git ls-remote --tags/heads url-of-repo
现在我想知道,哪个标签属于一个分支。 我可以做类似的事情

git branch --contains tags/<tag>
git分支--包含标记/
但我不想为了获取这些信息而在本地签出所有存储库。
也许有一个命令可以直接显示分支的所有标记?

制作一个克隆,一个裸克隆

git clone --bare url-of-repo
每次要列出分支时,首先更新分支和标记

cd path-to-the-bare-repo
git fetch origin +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/*
然后跑

git branch --contains tags/<tag>
或者干脆

GIT_DIR=path-to-the-bare-repo git fetch origin +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/*
GIT_DIR=path-to-the-bare-repo git for-each-ref refs/heads --contains tags/<tag> --format="%(refname:lstrip=2)"
GIT\u DIR=裸repo GIT获取原点的路径+refs/heads/*:refs/heads/*+refs/tags/*:refs/tags/*
GIT_DIR=每个ref/heads的裸repo GIT路径--包含标记/--format=“%(refname:lstrip=2)”
如果您不想进行本地克隆,并且您可以访问托管服务器。另一个选项是运行web服务来查询服务器托管的存储库中的分支。您可以使用
django
在几分钟内编写并运行这样的服务。

谢谢,--bare命令正是我所需要的
export GIT_DIR=path-to-the-bare-repo
git fetch origin +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/*
git for-each-ref refs/heads --contains tags/<tag> --format="%(refname:lstrip=2)"
unset GIT_DIR
GIT_DIR=path-to-the-bare-repo git fetch origin +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/*
GIT_DIR=path-to-the-bare-repo git for-each-ref refs/heads --contains tags/<tag> --format="%(refname:lstrip=2)"