[英]Git: How to fetch a single remote branch and create a remote-tracking branch of it automatically?
git fetch remote_repo
將從遠程存儲庫更新所有分支的“遠程跟蹤分支”。
如果我只需要獲取一個遠程分支怎么辦?
我試着跑:
git fetch remote_repo remote_branch
它只是將信息存儲到FETCH_HEAD
而不是創建名為remote_repo/remote_branch
的“遠程跟蹤分支”。
我知道有一個解決方案:
git fetch remote_repo remote_branch:refs/remotes/remote_repo/remote_branch
但它太冗長了。
有沒有更簡單的方法來實現這一目標?
如果要獲取的遠程分支集合稍微穩定,則可以使用git-config
編輯remote.<name>.fetch
以實現該結果:
git config remote.remote_repo.fetch remote_branch:refs/remotes/remote_repo/remote_branch
運行裸git fetch
時,該配置將被默認選中:
remote.<name>.fetch
The default set of "refspec" for git-fetch(1). See git-fetch(1).
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.