git 如何在特定分支上浅克隆存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21833870/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:45:07  来源:igfitidea点击:

How do I shallow clone a repo on a specific branch?

gitcontinuous-integrationgit-branchgit-cloneshallow-clone

提问by joseph.hainline

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.

但不要在特定分支上启动克隆。

回答by joseph.hainline

To clone repo foo.gitwith branch bardo:

要使用分支克隆 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