很多时候 git clone github 的项目下不来或者很慢,通常我们会设置终端的代理:

export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890

但我遇到一件很郁闷的事情,无论我怎么设置 git clone 的时候总是报错:

Failed to connect to 10.10.110.129 port 1080:...

这台电脑以前有人用过,所以立即想到是不是 git 里单独设置了代理,检查:

$ git config --list
credential.helper=osxkeychain
http.https://github.com.proxy=socks5://10.10.110.129:1080
...

果然,git 被设置了代理,优先级高于终端的代理(类似 CSS 的优先级)。

果断关闭之:

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

发现不work,此时才注意到只是对 github.com 采用了代理,取消命令如下:

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

执行后成功取消。

标签: git