设置命令行以及Git代理和增大git的http提交缓冲区

感觉之后大概率还会碰到,所以在这里也做个记录

代理相关的东西

Windows的命令行

# 使用sock5代理(伦琴射线系方案)
set http_proxy=socks5://127.0.0.1:10808
set https_proxy=socks5://127.0.0.1:10808
# 使用http代理(小猫咪系方案)
set http_proxy=http://127.0.0.1:7890
set https_proxy=http://127.0.0.1:7890

# 取消设置(对,等号后面是空的)
set http_proxy=
set https_proxy=

如需长期生效请将它写到系统的环境变量去

Git单独设置

//设置全局代理
//http
git config --global https.proxy http://127.0.0.1:10809
//https
git config --global https.proxy https://127.0.0.1:10809
//使用socks5代理的 例如ss,ssr 1080是windows下ss的默认代理端口,mac下不同,或者有自定义的,根据自己的改
git config --global http.proxy socks5://127.0.0.1:10808
git config --global https.proxy socks5://127.0.0.1:10808

//只对github.com使用代理,其他仓库不走代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
//取消github代理
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy

//取消全局代理
git config --global --unset http.proxy
git config --global --unset https.proxy

请记住,大部分时候命令行程序都是不会走系统代理的,除非你把代理直接挂网关上

Tips V2的默认http端口 10809 socket5 10808

对于Git Bash,建议使用socket5以防止出现奇奇怪怪的问题

缓冲区相关

C:\xxx>git push
Enumerating objects: 19, done.
Counting objects: 100% (19/19), done.
Delta compression using up to 16 threads
Compressing objects: 100% (14/14), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (15/15), 7.97 MiB | 737.00 KiB/s, done.
Total 15 (delta 9), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date

这是为了解决遇上这个问题而准备的,解决方案来自谷歌

你可能会在一次提交很多个commit的时候遇上这个问题

git config --global http.postBuffer 157286400

这行可以增大缓冲区,我就是用这个解决的

git config --global http.version HTTP/1.1
git push 
git config --global http.version HTTP/2

另一种方法就是上方的修改使用的http协议,但是我测试了一下没效果

后记

只是随便记一下笔记,所以没啥排版,凑合看看

感谢大佬们提前为我们找到了解决方案

参考资料

https://blog.csdn.net/sjhsxjsdb/article/details/127484388

https://stackoverflow.com/questions/59282476/error-rpc-failed-curl-92-http-2-stream-0-was-not-closed-cleanly-protocol-erro

*Windows的命令行 部分于2023.1.12日更新

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注