只克隆一个分支
问题描述:
我想知道如何只克隆一个分支而不是克隆整个 Git 存储库.
I would like to know how I could clone only one branch instead of cloning the whole Git repository.
答
来自公告 Git1.7.10(2012 年 4 月):
From the announcement Git 1.7.10 (April 2012):
-
git clone
学习了--single-branch
选项来限制克隆到单个分支(惊喜!);不会获取未指向分支历史记录的标签.
git clone
learned--single-branch
option to limit cloning to a single branch (surprise!); tags that do not point into the history of the branch are not fetched.
Git 实际上只允许你克隆一个分支,例如:
Git actually allows you to clone only one branch, for example:
git clone -b mybranch --single-branch git://sub.domain.com/repo.git
注意:另外您可以添加另一个单个分支或撤消"此操作.