本文記錄工作中遇到的
clone
大倉庫失敗的解決過程,以下問題與解決方案均基於https
訪問。
錯誤一
從web
端查看倉庫大小,大約1.5G
左右,首先直接執行git clone
,報錯如下:
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
認證:
$ git config --global http.postBuffer 2048000000 # 設置爲2G
$ git config --global http.sslVerify false # 關閉sslVerify
設置成功後,重新clone
,錯誤依舊。
使用openssl替換gunssl
1.安裝相關依賴環境:
$ sudo apt-get install build-essential fakeroot dpkg-dev libcurl4-openssl-dev
2.獲取git源碼:
$ sudo apt-get source git
若出現如下錯誤:
E: You must put some 'source' URIs in your sources.list
則需要將設置->Software & Updates
->Ubuntu Software
->Source code
勾選:
若出現如下錯誤:
couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied) [duplicate]
則需要更改權限:
sudo chown _apt /var/lib/update-notifier/package-data-downloads/partial/
3.安裝git
的依賴
$ sudo apt-get build-dep git
4.進入git
目錄,重新編譯:
$ 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.回到上一級目錄,安裝編譯好的安裝包:
$ cd ..
$ sudo dpkg -i git_2.7.4-0ubuntuxxx_amd64.deb # 安裝包名字可能有所不同
執行完成如上步驟後,重新clone
,發現依舊報錯,請看錯誤二。
錯誤二
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
,配置確實生效了:
$ cat ~/.gitconfig
[http]
sslVerify = false
postBuffer = 2048000000
淺層clone
暈,實在搞不定了,採取極端方法,首先clone
一層:
$ git clone --depth=1 http://xxx.git
淺層clone
成功後,再完整拉取:
$ git fetch --unshallow # 拉取完整當前分支
$ git remote set-branches origin '*' # 追蹤所有遠程分支
$ git fetch -v # 拉取所有遠程分支
至此,終於成功地clone
了一個完整的倉庫。
微信公衆號同步更新,微信搜索"AnSwEr不是答案"或者掃描二維碼,即可訂閱。
- GitHub:AnSwErYWJ
- Blog:http://www.answerywj.com
- Email:[email protected]
- Weibo:@AnSwEr不是答案