git 两种模式:SSH 、HTTP
proxy 两种模式:SOCKS 、HTTP
两两组合,共 4 种设置,请按需正确配置:
# 1. git http + proxy http
git config --global http.proxy "http://127.0.0.1:1080"
git config --global https.proxy "http://127.0.0.1:1080"
# 2. git http + proxy socks
git config --global http.proxy "socks5://127.0.0.1:1080"
git config --global https.proxy "socks5://127.0.0.1:1080"
# to unset
git config --global --unset http.proxy
git config --global --unset https.proxy
# 3. git ssh + proxy http
vim ~/.ssh/config
Host
github.comHostName
github.comUser git
ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=1087
# 4. git ssh + proxy socks
vim ~/.ssh/config
Host
github.comHostName
github.comUser git
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p