github速度慢是因为DNS被污染了,下面介绍的是使用代理的方法。
Git命令不会直接走全局代理,所以即使你开了VPN的全局代理速度也不会有变化。
这时候需要设置Git命令走VPN的代理端口。
# socks5协议,1080端口修改成自己的本地代理端口
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
# http协议,1081端口修改成自己的本地代理端口
git config --global http.proxy <http://127.0.0.1:1081>
git config --global https.proxy <https://127.0.0.1:1081>
以上的配置会导致所有git命令都走代理,但是如果你混合使用了国内的git仓库,甚至是局域网内部的git仓库,这就会把原来速度快的改成更慢的了;
下面是仅仅针对github进行配置,让github走本地代理,其他的保持不变;
# socks5协议,1080端口修改成自己的本地代理端口
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
# http协议,1081端口修改成自己的本地代理端口
git config --global http.<https://github.com.proxy> <https://127.0.0.1:1081>
git config --global https.<https://github.com.proxy> <https://127.0.0.1:1081>
其他几个相关命令:
# 查看所有配置
git config -l
# reset 代理设置
git config --global --unset http.proxy
git config --global --unset https.proxy