Git use a proxy
2021-01-21
最近在 clone Github 上的一个项目的时候,速度只有几 KB,然后尝试使用全局代理、终端命令代理,都没什么效果,查询了一下相关资料才知道上面尝试的两种方式只对 https 地址有效果,ssh 的地址不生效。
如果是使用的 http 地址,那按普通的方式代理就应该会生效
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
但我一直习惯使用 ssh 的地址,所以这里就要正对 ssh 的地址专门设置一下代理,如下:
Host github.com
HostName github.com
User git
ProxyCommand nc -v -x x.x.x.x:xxx %h %p
开始享受高速 clone 的快乐吧 :)