Git中设置代理和取消代理

设置git@走代理

  1. 修改~/.ssh/ssh_config
  2. 添加ProxyCommand nc -x 127.0.0.1:1080 %h %p到需要的ssh主机地址上
  3. 如果不确定,或希望全部走代理,则添加到第一行

设置Socks5代理

git config --global http.proxy 'socks5://127.0.0.1:1080' && git config --global https.proxy 'socks5://127.0.0.1:1080'

设置http/https代理

git config --global https.proxy http://127.0.0.1:1080 && git config --global https.proxy https://127.0.0.1:1080

取消代理

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

强制转换协议以使用代理

git config --global url."https://github".insteadOf git://github
git config --global url."git@github.com:".insteadOf "https://github.com/"
git config --global url.ssh://git@bitbucket.org/.insteadOf https://bitbucket.org/

参考资料:https://www.cnblogs.com/xueweihan/p/7242577.html https://gist.github.com/Kovrinic/ea5e7123ab5c97d451804ea222ecd78a
posted @ 2018-02-01 13:03  zhuxiaoxi  阅读(9626)  评论(0编辑  收藏  举报