如何在特定分支上浅层克隆回购?

jos*_*ine 63 git continuous-integration git-clone shallow-clone git-branch

如何浅登克隆git存储库,以便我的克隆只包含1个历史记录项,并在特定分支上启动?

我知道如何做一个浅层克隆:

git clone --depth 1 https://path/to/myrepo.git
Run Code Online (Sandbox Code Playgroud)

但不能在特定分支上启动克隆.

jos*_*ine 113

要使用分支克隆repo foo.git,请执行以下操作:

git clone --depth 1 https://path/to/repo/foo.git -b bar
Run Code Online (Sandbox Code Playgroud)

请参阅git-clone文档:https://www.kernel.org/pub/software/scm/git/docs/git-clone.html

  • 您可以使用--no - single - branch而不是-b bar来下载所有分支的第一个提交表单. (12认同)
  • 我认为您的意思是“-不单分支”而不是“-不-单分支”。 (5认同)
  • `-b` 更详细的版本是 `--branch` (2认同)