Git 下载大型文件错误修复

发布于:2022-10-13 ⋅ 阅读:(779) ⋅ 点赞:(0)

系统环境:Ubuntu 20.04

  • 问题1
error: gnutls_handshake() failed: A TLS packet with unexpected length was received. while accessing …
fatal: HTTP request failed

  • 问题2
warning: redirecting to https:// xxxx .git/
error: RPC failed; HTTP 302 curl 22 The requested URL returned error: 302
fatal: the remote end hung up unexpectedly
  • 分析

    • http.followRedirects 不能自动跳造成此问题
    • 或者git版本不完整,下载大仓库代码时会出现此错误
  • 解决

    • 尝试通过重新编译安装 链接:Git 的编译安装
    • 终端输入
      git config --global http.xxx.git.followRedirects "true"
      xxxhttps.xxx.git
  • ~/.gitconfig 添加

      - 与终端添加的方式同理
    
    //添加la的地址
    [http "https:// xxx .git"]
    followRedirects = true
    

  • 问题3
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
  • 分析
    • curl的postBuffer的默认值太小,我们需要调整它的大小
    • 网速问题也会造成影响
  • 解决
    • 终端输入
      git config --global http.postBuffer 524288000
      ~/.gitconfig 添加 与终端添加的方式同理

      //这里改成1G了,500M仍然会报错
      [http]
      postBuffer = 1073741824
      
    • ~/.gitconfig 添加

    • 与终端添加的方式同理

      [http]
      postBuffer = 1073741824
      lowSpeedLimit = 0
      lowSpeedTime = 999999
      

  • 问题4
    error: RPC failed; curl 56 GnuTLS recv error (-9): Error decoding the received TLS packet.
    fatal: the remote end hung up unexpectedly
    fatal: early EOF
    fatal: index-pack failed
    
  • 解决
    sudo apt-get install gnutls-bin
    #上述已经配置好,无需重复配置
    git config --global http.sslVerify false
    git config --global http.postBuffer 1048576000
    #临时修改mtu 
    ifconfig eth0 mtu 9000
    
本文含有隐藏内容,请 开通VIP 后查看