从github上获取资源速度慢的解决办法

今天在github上clone一个仓库的时候,速度非常慢,只有3kb/s,开代理也没用,网上找到的各种git config的方法也没有用,最后想到设置hosts试试。于是在git的安装目录下找到了/etc/hosts这个文件,在里面添加了github与它的服务器地址的对应关系192.30.253.112 github.com,服务器地址利用ping github.com得到。

这样设置了以后,速度得到了明显的提升,差不多可以达到100kb/s了,效果非常不错。


不知道为什么今天使用的时候上面的方法失效了,在网上搜索到的方法发现一个配合shadowsocks使用更有效的:
$ git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
$ git config --global https.proxy https://proxyuser:proxypwd@proxy.server.com:8080
其中http和https协议可以改成这样socks5://127.0.0.1:1080(配合shadowsocks)

使用上面的命令配置完之后,会在 ~/.gitconfig 文件中多出几行:

[http]
proxy = http://proxyuser:proxypwd@proxy.server.com:8080
[https]
proxy = https://proxyuser:proxypwd@proxy.server.com:8080
你也可以使用下面的命令检查配置是否生效:

$ git config --global --get http.proxy
$ git config --global --get https.proxy
另外,如果你想取消该设置,可以:

$ git config --global --unset http.proxy
$ git config --global --unset https.proxy

原文地址:https://www.cnblogs.com/biyesheng/p/6039760.html