簡體   English   中英

GitLab API 如何找到特定提交的分支名稱

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM