问题描述
在家工作期间,我的带宽不足以克隆存储库。我已经尝试了大约10次来克隆回购协议,但是不走运。
Receiving objects: 91% (54330/59387),445.67 MiB | 44.00 KiB/s
Receiving objects: 91% (54506/59387),445.80 MiB | 46.00 KiB/s
Receiving objects: 91% (54635/59387),445.86 MiB | 45.00 KiB/s
Receiving objects: 92% (54637/59387),445.86 MiB | 45.00 KiB/s
Receiving objects: 92% (54721/59387),445.92 MiB | 38.00 KiB/s
Receiving objects: 92% (54782/59387),445.99 MiB | 43.00 KiB/s
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack Failed
有什么办法可以接收剩余的8%的物体?让我知道是否有git clone的任何属性可以帮助我解决这个问题。我可以,即使Visual Studio或Visual Studio Code中有一种方法可以实现相同目标。
我见过"How to complete a git clone for a big project on an unstable connection?"。它说明了如果您要从头开始的话该怎么做。我正在寻找的是如何在不重新启动克隆的情况下继续前进。
解决方法
尝试从浅表克隆开始:
git clone --depth 1 <repo>
然后您可以尝试取消回购:
git fetch --unshallow origin
如果失败,您可以尝试先迭代增加深度:
git fetch --depth 10 origin master
git fetch --depth 20 origin master
...
并可能一个一个地获取分支:
git fetch --depth 1 origin branch1
git fetch --depth 10 origin branch1
...
直到git fetch --unshallow
通过。
另一种方法是仅复制任何现有克隆中的文件。
假设您可以通过ssh访问不存在带宽问题的服务器:
ssh <server-with-bandwidth>
[remote]$ git clone <repo>
然后,您只需要将remote:repo/
的内容(包括其.git/
目录,其中包含所有克隆的历史记录)复制到您的PC上。
您可以使用scp
,sftp
,rsync
...或任何允许恢复故障的工具。
很显然,请遵循贵公司的安全准则:选择在其上可以克隆代码的远程服务器,在使用完无用的克隆后将其删除,等等...