在Git Extensions中,用户在克隆存储库时,可以指定在生成的克隆中检出哪个分支(可能不是master
)。
如何在命令行执行此操作?
答案 0 :(得分:2)
答案通常在手册页中(在git-clone
手册页中,在这里):
--branch <name>, -b <name>
Instead of pointing the newly created HEAD to the branch pointed
to by the cloned repository's HEAD, point to <name> branch
instead. In a non-bare repository, this is the branch that will
be checked out. --branch can also take tags and detaches the
HEAD at that commit in the resulting repository.
所以你想要运行
git clone --branch <name> <repository>
其中<name>
代表您要在<repository>
克隆中检出的分支的名称。
$ cd ~/Desktop
$ git clone --branch maint https://github.com/git/git
$ cd git
$ git branch
* maint