[英]GitLab API How to find branch name for specific commit
我试图找到标签和分支名称之间的联系。 使用这个:
GET v4/projects/:id/repository/tags?page=1&per_page=1
我得到最后一个标签和提交 ID。 我需要找到具有特定提交的分支名称。 如何获取具有特定提交 ID 的分支? 我试过了 ”
GET v4/projects/:id/repository/commits/:short_id
- 但提交中没有分支名称
v4/projects/id:/repository/branches?short_id="specific_id
- 返回所有分支:(
这一切都是因为我需要拉本地然后推送到远程特定标签
假设我有 3 个分支 R_1.0、R_2.0 和 R_3.0。 有人推了新的 TAG 3.0。 我需要找到连接到此 TAG 的提交,然后是 BRANCH 名称...
可能没有。 标签可以命名任何分支名称都无法访问的提交。
...因为我需要将这个分支拉到本地存储库,然后推送到远程存储库。 这都是关于在两个远程存储库之间推送标签......
如果您只是想通过本地存储库获取标签 $T 及其标记的提交,从远程 $r1 到远程 $r2,您不需要 go 通过所有这些疯狂。 做就是了:
die() {
echo "fatal: $@"
exit 1
}
# e.g., r1=origin and r2=upstream, T=v1.2
# obtain the specific tagged commit and its history, using the
# same tag name locally, from remote r1
git fetch $r1 refs/tags/$T:refs/tags/$T || die "fetch from $r1 failed"
# then send that commit and the tag name to remote r2
git push $r2 refs/tags/$T:refs/tags/$T || die "push to $r2 failed"
(注意上面的脚本没有经过测试。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.