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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM