1. 报错信息
bash
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (8/8), done.
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (8/8), 1.18 MiB | 1.11 MiB/s, done.
Total 8 (delta 0), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung
2. 解决
问了Qwen等LLM,没用,还是stackoverflow
根据:
- Git push failure while pushing a large respository of code
- Git error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400 send-pack: unexpected disconnect while reading sideband packet
执行以下操作:
bash
# 方法1 把要push的内容分多次push,先回退,再分多次提交
# 方法2,临时修改 buffer size,提交完再改回去,防止吃内存
git config http.postBuffer 524288000
git pull && git push
git config --unset http.postBuffer
3. 原因探索
不一定是网络原因,而是 buffer size的问题
bash
# 查看日志中关于http传输的信息
> GIT_CURL_VERBOSE=1 GIT_TRACE=1 git push 2>&1 | grep -A 10 "HTTP"
09:17:04.433505 http.c:701 == Info: CONNECT tunnel: HTTP/1.1 negotiated
09:17:04.433509 http.c:701 == Info: allocate connect buffer
# 分配缓存
09:17:04.433515 http.c:701 == Info: Establish HTTP proxy tunnel to github.com:443
09:17:04.433557 http.c:648 => Send header, 0000000127 bytes (0x0000007f)
09:17:04.433564 http.c:660 => Send header: CONNECT github.com:443 HTTP/1.1
09:17:04.433567 http.c:660 => Send header: Host: github.com:443
09:17:04.433570 http.c:660 => Send header: User-Agent: git/2.39.2 (Apple Git-143)
09:17:04.433573 http.c:660 => Send header: Proxy-Connection: Keep-Alive
09:17:04.433575 http.c:660 => Send header:
09:17:04.433753 http.c:648 <= Recv header, 0000000037 bytes (0x00000025)
09:17:04.433761 http.c:660 <= Recv header: HTTP/1.1 200 Connection established
09:17:04.433775 http.c:648 <= Recv header, 0000000002 bytes (0x00000002)
09:17:04.433778 http.c:660 <= Recv header:
09:17:04.433783 http.c:701 == Info: CONNECT phase completed
09:17:04.433787 http.c:701 == Info: CONNECT tunnel established, response 200
09:17:04.433840 http.c:701 == Info: ALPN: curl offers h2,http/1.1
09:17:04.433996 http.c:701 == Info: (304) (OUT), TLS handshake, Client hello (1):
09:17:04.441583 http.c:701 == Info: CAfile: /etc/ssl/cert.pem
09:17:04.441600 http.c:701 == Info: CApath: none
09:17:05.517635 http.c:701 == Info: (304) (IN), TLS handshake, Server hello (2):
09:17:05.517918 http.c:701 == Info: (304) (IN), TLS handshake, Unknown (8):
--
09:17:05.521669 http.c:701 == Info: using HTTP/2
09:17:05.521703 http.c:701 == Info: [HTTP/2] [1] OPENED stream for https://github.com/XXX/XXX.git/info/refs?service=git-receive-pack
09:17:05.521708 http.c:701 == Info: [HTTP/2] [1] [:method: GET]
09:17:05.521710 http.c:701 == Info: [HTTP/2] [1] [:scheme: https]
09:17:05.521713 http.c:701 == Info: [HTTP/2] [1] [:authority: github.com]
09:17:05.521715 http.c:701 == Info: [HTTP/2] [1] [:path: /XXXX/XXXX.git/info/refs?service=git-receive-pack]
09:17:05.521718 http.c:701 == Info: [HTTP/2] [1] [user-agent: git/2.39.2 (Apple Git-143)]
09:17:05.521721 http.c:701 == Info: [HTTP/2] [1] [accept: */*]
09:17:05.521723 http.c:701 == Info: [HTTP/2] [1] [accept-encoding: deflate, gzip]
09:17:05.521726 http.c:701 == Info: [HTTP/2] [1] [pragma: no-cache]
# 这里显示 no_cache 所以真的是缓存不够了????
09:17:05.521751 http.c:648 => Send header, 0000000198 bytes (0x000000c6)
09:17:05.521756 http.c:660 => Send header: GET /xxx/xxx.git/info/refs?service=git-receive-pack HTTP/2
09:17:05.521759 http.c:660 => Send header: Host: github.com
09:17:05.521761 http.c:660 => Send header: User-Agent: git/2.39.2 (Apple Git-143)
09:17:05.521764 http.c:660 => Send header: Accept: */*
09:17:05.521767 http.c:660 => Send header: Accept-Encoding: deflate, gzip
09:17:05.521769 http.c:660 => Send header: Pragma: no-cache
09:17:05.521771 http.c:660 => Send header:
09:17:05.521781 http.c:701 == Info: Request completely sent off
09:17:05.898901 http.c:648 <= Recv header, 0000000013 bytes (0x0000000d)
09:17:05.898912 http.c:660 <= Recv header: HTTP/2 401
09:17:05.898919 http.c:648 <= Recv header, 0000000026 bytes (0x0000001a)
09:17:05.898922 http.c:660 <= Recv header: server: GitHub-Babel/3.0
09:17:05.898927 http.c:648 <= Recv header, 0000000054 bytes (0x00000036)
09:17:05.898929 http.c:660 <= Recv header: content-security-policy: default-src 'none'; sandbox
09:17:05.898934 http.c:648 <= Recv header, 0000000041 bytes (0x00000029)
09:17:05.898936 http.c:660 <= Recv header: content-type: text/plain; charset=UTF-8
09:17:05.898940 http.c:648 <= Recv header, 0000000040 bytes (0x00000028)
09:17:05.898943 http.c:660 <= Recv header: www-authenticate: Basic realm="GitHub"
09:17:05.898958 http.c:648 <= Recv header, 0000000020 bytes (0x00000014)
09:17:05.898966 http.c:660 <= Recv header: content-length: 21