【问题标题】:How do I shallow clone a repo on a specific branch?如何在特定分支上浅克隆 repo?
【发布时间】:2014-03-17 00:45:45
【问题描述】:

我如何浅克隆一个 git 存储库,以便我的克隆只包含 1 个历史记录项,并从特定分支开始?

我知道如何进行浅层克隆:

git clone --depth 1 https://path/to/myrepo.git

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

【问题讨论】:

    标签: git continuous-integration git-branch git-clone shallow-clone


    【解决方案1】:

    要克隆 repo foo.git 与分支 bar 做:

    git clone --depth 1 https://path/to/repo/foo.git -b bar
    

    查看 git-clone 文档:https://www.kernel.org/pub/software/scm/git/docs/git-clone.html

    【讨论】:

    • 您可以使用--no--single--branch 代替-b bar,下载所有分支的第一个提交。
    • 我认为您的意思是 --no-single-branch 而不是 --no--single--branch
    • -b 更详细的版本是--branch
    猜你喜欢
    • 1970-01-01
    • 2011-06-23
    • 2017-05-05
    • 2015-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 2020-09-28
    相关资源
    最近更新 更多