我正在從 Gitlab CI 的上游管道觸發下游管道。
我想檢查下游 repo 中是否有與上游分支同名的分支,但我不想為了做某事而克隆整個下游 repo git branch --list。
基本上,我正在尋找一個僅檢查遠程存盤庫中是否存在分支的單行程式。
任何意見,將不勝感激。謝謝!
uj5u.com熱心網友回復:
就在這里。您可以使用git ls-remote. 例如,如果您想查看 Git 存盤庫中的分支,您可以這樣做:
$ git ls-remote https://github.com/git/git.git refs/heads/*
69a9c10c95e28df457e33b3c7400b16caf2e2962 refs/heads/main
e9d7761bb94f20acc98824275e317fa82436c25d refs/heads/maint
69a9c10c95e28df457e33b3c7400b16caf2e2962 refs/heads/master
a2b2bfdf31eaee062391d5f278d6dd93cf7a3e4c refs/heads/next
03adea34405149b89748ff7ea766e1c7f06430cd refs/heads/seen
510d42bf652ebc22ceb54ba76b4d9023320194fa refs/heads/todo
例如,您可以指定refs/heads/main是否需要,并查看是否有任何輸出。這個命令在存盤庫之外作業得很好。您可以查看手冊頁以獲取更多選項。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/386564.html
