解决Git拉取代码慢问题

1,007 阅读1分钟

首先你得需要有代理。

Git代理设置

因为Git默认没有走代理,需要配置代理。针对HTTP,SSH无效。

设置代理

全局代理

git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890

局部代理,在github clone 仓库内执行

git config --local http.proxy 127.0.0.1:7890
git config --local https.proxy 127.0.0.1:7890

只给GitHub添加代理,GitHub添加全局代理会影响国内仓库

git config --global http.https://github.com.proxy https://127.0.0.1:7890
git config --global https.https://github.com.proxy https://127.0.0.1:7890

127.0.0.1:7890这个地址参考自己的实际地址: 代理地址.png

查询是否使用代理

查询全局代理:

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

查询局部代理:

git config --local http.proxy
git config --local https.proxy

取消代理:

git config --global --unset http.proxy
git config --local --unset http.proxy