即使你使用了全局代理,系统中还是有一些软件,不走代理的。需要你单独配置
git设置代理
HTTP 形式
走 HTTP 代理
git config --global http.proxy "http://127.0.0.1:7890" git config --global https.proxy "http://127.0.0.1:7890"
|
走 socks5 代理(如 Shadowsocks)
git config --global http.proxy "socks5://127.0.0.1:7890" git config --global https.proxy "socks5://127.0.0.1:7890"
|
取消设置
git config --global --unset http.proxy git config --global --unset https.proxy
|
SSH 形式
修改 ~/.ssh/config
文件(不存在则新建):
# 必须是 github.com Host github.com HostName github.com User git # 走 HTTP 代理 # ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=8080 # 走 socks5 代理(如 Shadowsocks) # ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
|
终端走代理
mac端
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
|
- 每次打开新的终端都需要重新配置
ping
命令不通的原因
Ping
走的是 ICMP 协议,代理软件走的是 TCP/IP 协议
可以使用 curl -vv http://www.google.com
来验证
- 没通

- 通了

Windows端
set https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
|
参考链接
https://zcdll.github.io/2018/01/27/proxy-on-windows-terminal/