git
主要使用两种协议:HTTPS
和ssh
。需要分别设置代理。
为git
设置HTTPS
代理:
git config --global http.proxy "socks5h://127.0.0.1:1080"
# 仅为github设置代理:
git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080
为git
设置SSH
代理有两种思路方法:
Host github.com
User git
# 使用nc,ssh走代理
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
# 使用vps作为ssh跳板做代理
ProxyCommand ssh -q -W %h:%p vps
同时,Github支持SSH over HTTPS
,即:Using SSH over the HTTPS port。
通过如下设置:
Host github.com
Hostname ssh.github.com
Port 443
SSH
协议流量走HTTPS
协议。
再继续设置终端https代理即可。(目前访问ssh.github.com
这个域名似乎没什么问题)