git push/git clone代码速度太慢

一、解决git push/git clone代码速度太慢:

1.使用管理员权限打开hosts文件

sudo vim /etc/hosts

2.在该文件末尾空一行填入

151.101.72.249 github.global.ssl.fastly.net

修改之后速度由10k20k左右增到500k-1000k左右

二、检出大项目报错,curl的postBuffer默认值太小:

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 (这个值是kb 500M,根据具体项目大小修改)

然后检查一下是否配置成功:

git config --list

三、还有一方法

解决方法

配置 git push 直接走网络代理

# 设置全局代理
# http
git config --global https.proxy http://127.0.0.1:1080
# https
git config --global https.proxy https://127.0.0.1:1080
# 使用socks5代理的 例如ss,ssr 1080是windows下ss的默认代理端口,mac下不同,或者有自定义的,根据自己的改
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
 
# 只对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

其中 1080 是 SOCKS 代理的端口,一般默认 1080,可以在代理工具的设置中查看。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值