- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有一个 git 存储库,我想对其进行浅拷贝,并且只提取一个分支。
This SO question说默认情况下 git clone 会 pull 所有远程分支。我只想对一个分支进行浅拷贝。
我这样做是为了部署到生产环境中。一个完整的 checkout 超过 400MB,但是一个 head 的 git archive 只有 16MB。看起来克隆的 pull 下所有分支的行为导致我的下载比需要的大得多。
最佳答案
Jakub已经提到了 shallow clone of selected branches is possible ,但做起来相当复杂。
他补充说:
Note however that because branches usually share most of their history, the gain from cloning only a subset of branches might be smaller than you think.
我要补充一点,您不应该在生产平台中安装任何 VCS 工具(您只安装/监控生产运行所必需的工具)。
所以git archive
仍然是提取所需内容的最佳方式,作为存档(zip
或 tar
,一旦在生产端传输,您就可以在没有 Git 的情况下使用这种格式)
2012 年 3 月更新:
upcoming git1.7.10 (2012 年 4 月)实际上只允许克隆一个分支:
git clone --single-branch
你可以在t5500-fetch-pack.sh
中看到它:
test_expect_success 'single branch clone' '
git clone --single-branch "file://$(pwd)/." singlebranch
'
该功能随后通过以下方式修复:
clone --single
: 限制 fetch refspec 到 fetched branchAfter running "
git clone --single
", the resulting repository has the usual default "+refs/heads/*:refs/remotes/origin/*
" wildcard fetch refspec installed, which means that a subsequent "git fetch
" will end up grabbing all the other branches.Update the fetch refspec to cover only the singly cloned ref instead to correct this.
gitster
),Git 2.0.2,2014 年 7 月)31b808a (
clone --single
: limit the fetch refspec to fetched branch, 2012-09-20) tried to see if the given "branch" to follow is actually a tag at the remote repository by checking with "refs/tags/
" but it incorrectly usedstrstr(3)
; it is actively wrong to treat a "branch" "refs/heads/refs/tags/foo
" and use the logic for the "refs/tags/
" ref hierarchy.
What the code really wanted to do is to see if it starts with "refs/tags/
".
2016 年 9 月更新:git clone --single-branch --branch tag
will work for chained tags在 Git 2.11+(2016 年第 4 季度)中。
关于git - 如何浅克隆git中的单个分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4929688/
免责声明 这篇文章是关于术语“浅拷贝”和“深拷贝”的正确用法,特别是在谈论复制一个不包含任何引用的对象时。这个问题并不意味着(也不应该)基于意见,除非真的没有关于这个话题的共识。我已将此问题标记为 C
我有这个功能 int getrelation(string name, RELATION& output){ bool found=0; int index=0;
与 why should I make a copy of a data frame in pandas 有关 我注意到在流行的backtesting图书馆, def __init__(self, d
我的问题很基础,但我想 100% 理解所有内容。 SO中的很多问题都引用了我的帖子,但我没有找到满意的答案。 我们知道java中的枚举是引用类型。让我们考虑以下片段: public static cl
请引用这个 fiddle 的问题。 http://jsfiddle.net/AQR55/ 1)为什么附加到隔离范围属性的 watch - 双向绑定(bind)到父属性,不会在更改父范围属性时触发。 在
我想使用 UP3 来完成一项非常具体的任务,我应该能够使用 API 来实现该任务。我想了解是否可以编写以下应用程序。 基于https://jawbone.com/support/articles/00
如何在辅助方法中传递上下文并提取数据? 请参阅以下代码片段: import AppContext from '../../context/AppContext' import extractDatta
我正在尝试使用 simple-git 创建浅克隆。我正在尝试创建与此命令等效的命令:git clone --depth 1 https://github.com/steveukx/git-js.git
我是一名优秀的程序员,十分优秀!