使用 --depth 1 克隆后使用 git 拉取更新
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23986685/
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
Pull updates with git after cloned with --depth 1
提问by matec
This morning I made a shallow clone of the Linux sources
今天早上我对 Linux 源代码做了一个浅薄的克隆
git clone --depth 1 https://github.com/torvalds/linux.git
which resulted in a linux
folder of 851Mb.
这导致了一个linux
851Mb的文件夹。
Now I would like to pull the latest changes, but
现在我想提取最新的更改,但是
git pull
starts a seemly huge download. After 60Mb I'm at 3% which extrapolates to 2Gb. However, the 5 commits since my clone change only a bunch of lines.
开始一个看似巨大的下载。在 60Mb 之后,我处于 3%,推断为 2Gb。但是,由于我的克隆只更改了一堆行,所以 5 次提交。
Am I doing something wrong? What are the 2Gb that git
tries to download?
难道我做错了什么?git
尝试下载的 2Gb 是什么?
回答by mgarciaisaia
I think you can use --depth 1
in git pull
too, so it gets just what's needed for the newest commit in the repository.
我认为您也可以使用--depth 1
in git pull
,因此它可以获取存储库中最新提交所需的内容。
I don't know if the default behaviour is to pull everything missing, because my git help pull
shows this option:
我不知道默认行为是否是拉出所有丢失的东西,因为我git help pull
显示了这个选项:
git pull --unshallow
or
或者
git fetch --unshallow
--unshallow Convert a shallow repository to a complete one, removing all the limitations imposed by shallow repositories.
--unshallow 将浅存储库转换为完整存储库,消除浅存储库强加的所有限制。
I'm running git version 1.8.5.2 (Apple Git-48)
, and maybe this is some sort-of-new behaviour, and changing a bit between versions.
我正在运行git version 1.8.5.2 (Apple Git-48)
,也许这是某种新行为,并且在版本之间有所改变。
回答by Andreas Wederbrand
Could any of the new commits be merge-commits pointing to commits not present in your tree? Perhaps --depth 1000
would work better and still be small enough.
是否有任何新提交是指向树中不存在的提交的合并提交?也许--depth 1000
会工作得更好,而且仍然足够小。