How do I shallow clone a git repository, so that my clone contains only 1 history item, and starts on a specific branch?
如何浅登克隆git存储库,以便我的克隆只包含1个历史记录项,并在特定分支上启动?
I know how to do a shallow clone:
我知道如何做一个浅层克隆:
git clone --depth 1 https://path/to/myrepo.git
but not start the clone on a specific branch.
但不能在特定分支上启动克隆。
1 个解决方案
#1
68
To clone repo foo.git with branch bar do:
要使用分支栏克隆repo foo.git,请执行以下操作:
git clone --depth 1 https://path/to/repo/foo.git -b bar
See the git-clone documentation: https://www.kernel.org/pub/software/scm/git/docs/git-clone.html
请参阅git-clone文档:https://www.kernel.org/pub/software/scm/git/docs/git-clone.html
#1
68
To clone repo foo.git with branch bar do:
要使用分支栏克隆repo foo.git,请执行以下操作:
git clone --depth 1 https://path/to/repo/foo.git -b bar
See the git-clone documentation: https://www.kernel.org/pub/software/scm/git/docs/git-clone.html
请参阅git-clone文档:https://www.kernel.org/pub/software/scm/git/docs/git-clone.html