我如何指定应该在新克隆中检出哪个分支? [英] How can I specify which branch should be checked out in a fresh clone?
本文介绍了我如何指定应该在新克隆中检出哪个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Git扩展中,用户可以在克隆存储库时指定应该在生成的克隆中检出哪个分支(可能不是 master
)。
如何在命令行执行该操作? 解答方案
通常情况下,在手册页中(在 git-clone
手册页中,在这里):
- branch< name>,-b< name>
不是将新创建的HEAD指向由克隆存储库的HEAD指向
的分支,而是指向< name>分支
。在非裸仓库中,这是将检出
的分支。 --branch还可以获取标签,并在生成的存储库中提交时分离
HEAD。
所以你想运行
git clone --branch< name> <库>
其中< name>
代表您想要在< repository>
的克隆中签出的分支名称。
示例
$ cd〜/桌面
$ git clone --branch maint https: //github.com/git/git
$ cd git
$ git branch
* maint
In Git Extensions, the user can, when cloning a repository, specify which branch (possibly other than master
) should be checked out in the resulting clone.
How can I do that at the command line?
解决方案
The answer, as often, is in the man pages (in the git-clone
man page, here):
--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.
So you want to run
git clone --branch <name> <repository>
where <name>
stands for the name of the branch that you want checked out in your clone of <repository>
.
Example
$ cd ~/Desktop
$ git clone --branch maint https://github.com/git/git
$ cd git
$ git branch
* maint
这篇关于我如何指定应该在新克隆中检出哪个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文