20

Git仓库过大导致clone失败的解决方法

 4 years ago
source link: https://answerywj.com/2019/09/09/git-clone-extra-large-project/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Git仓库过大导致clone失败的解决方法

2019-09-09

| Git

| 0

|

本文记录工作中遇到的clone大仓库失败的解决过程,以下问题与解决方案均基于https访问。


web端查看仓库大小,大约1.5G左右,首先直接执行git clone,报错如下:

1
2
3
4
5
6
remote: Counting objects: 10994, done.
remote: Compressing objects: 100% (3085/3085), done.
error: RPC failed; curl 56 GnuTLS recv error (-110): The TLS connection was non-properly terminated.
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

增大postBuffer

在增大postBuffer的同时,关闭ssl认证:

1
2
$ git config --global http.postBuffer 2048000000 # 设置为2G
$ git config --global http.sslVerify false # 关闭sslVerify

设置成功后,重新clone,错误依旧。

使用openssl替换gunssl

1.安装相关依赖环境:

1
$ sudo apt-get install build-essential fakeroot dpkg-dev libcurl4-openssl-dev

2.获取git源码:

1
$ sudo apt-get source git

若出现如下错误:

1
E: You must put some 'source' URIs in your sources.list

则需要将设置->Software & Updates->Ubuntu Software->Source code勾选:

source_code

若出现如下错误:

1
couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied) [duplicate]

则需要更改权限:

1
sudo chown _apt /var/lib/update-notifier/package-data-downloads/partial/

3.安装git的依赖

1
$ sudo apt-get build-dep git

4.进入git目录,重新编译:

1
2
3
4
$ cd git-2.7.4/
$ vim ./debian/control # 将libcurl4-gnutls-dev修改为libcurl4-openssl-dev
$ vim ./debian/rules # 整行删除TEST=test
$ sudo dpkg-buildpackage -rfakeroot -b -uc -us -j4 # 编译

5.回到上一级目录,安装编译好的安装包:

1
2
$ cd ..
$ sudo dpkg -i git_2.7.4-0ubuntuxxx_amd64.deb # 安装包名字可能有所不同

执行完成如上步骤后,重新clone,发现依旧报错,请看错误二。

1
2
3
4
5
6
remote: Counting objects: 10994, done.
remote: Compressing objects: 100% (3085/3085), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

重新确认postBuffer,配置确实生效了:

1
2
3
4
5
$ cat ~/.gitconfig

[http]
sslVerify = false
postBuffer = 2048000000

浅层clone

晕,实在搞不定了,采取极端方法,首先clone一层:

1
$ git clone --depth=1 http://xxx.git

浅层clone成功后,再完整拉取:

1
2
3
$ git fetch --unshallow # 拉取完整当前分支
$ git remote set-branches origin '*' # 追踪所有远程分支
$ git fetch -v # 拉取所有远程分支

至此,终于成功地clone了一个完整的仓库。

Reference

About me

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
本作品采用知识共享署名-相同方式共享 4.0 国际许可协议进行许可。


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK