我试图git克隆LibreOffice代码库,但目前我有一个大约300kbps的互联网连接,它只是什么都不稳定。我可以在任何时候恢复连接,但是git克隆进程已经停止工作,没有办法让它再次运行。有没有什么方法可以让git克隆下载更具抗失败性?

我自己考虑的一个选择是下载别人的.git目录,但这过于依赖他人,对我来说似乎不是最好的解决方案。


当前回答

对我来说最有效的解决方法是:

我也遇到过同样的问题,因为网络连接不好。所以我想出了以下解决方案:

我在服务器上创建了一个小的php文件,以zip文件的形式下载包:

<?php
$url = "https://codeload.github.com/CocoaPods/Specs/zip/master";
file_put_contents("coco.zip", fopen($url, 'r'));
?>  

<a href="coco.zip">coco.zip</a>

然后使用任何支持恢复的下载管理器下载zip文件。

其他回答

对我来说最有效的解决方法是:

我也遇到过同样的问题,因为网络连接不好。所以我想出了以下解决方案:

我在服务器上创建了一个小的php文件,以zip文件的形式下载包:

<?php
$url = "https://codeload.github.com/CocoaPods/Specs/zip/master";
file_put_contents("coco.zip", fopen($url, 'r'));
?>  

<a href="coco.zip">coco.zip</a>

然后使用任何支持恢复的下载管理器下载zip文件。

该方法使用第三方服务器。

首先,做 Git克隆——裸的,然后 rsync -v -P -e ssh user@host:repo。git。 Windows下可以使用msys。

我想到的两种解决方案(或者说是变通方法)是:

Use shallow clone i.e. git clone --depth=1, then deepen this clone using git fetch --depth=N, with increasing N. You can use git fetch --unshallow (since 1.8.0.3) to download all remaining revisions. Ask somebody to bundle up to some tagged release (see git-bundle(1) manpage). The bundle itself is an ordinary file, which you can download any way, via HTTP/FTP with resume support, via BitTorrent, via rsync, etc. The you can create clone from bundle, fix configuration, and do further fetches from official LibreOffice repository.

让我们把git克隆分解成它的组成部分,并使用git签出来防止重新下载文件。

当git克隆运行时,它所做的前几件事等同于

git init
git remote add origin <repo_url>
git fetch origin <branch>

如果您手动运行上述步骤,并假设它们正确完成,您现在可以根据需要多次运行以下步骤:

git checkout --force <branch>

请注意,每次运行时它都会检出所有文件,但您不必重新下载文件,这可能会节省大量时间。

我想把我的5美分放在这里。 这实际上帮助我解决了这个问题

关闭压缩 增加http.postBuffer 做部分克隆 导航到克隆目录并获取克隆的其余部分 拉动剩下的部分

git config --global core.compression 0
git config --global https.postBuffer 524288000
git clone  <your_git_http_url_here> --depth 1
git fetch --unshallow 
git pull --all

这帮助我在8Mbps adsl连接上克隆~3GB的repo,当然我必须执行取回和拉几次,但仍然…