git如何设置使用代理


使用命令直接设定socks或者http代理即可。

socks代理:

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

也可以直接修改~/.gitconfig文件。

vi ~/.gitconfig

新建或修改这两项配置

[http]
proxy = socks5://127.0.0.1:1080
[https]
proxy = socks5://127.0.0.1:1080

http/https代理

git config --global https.proxy http://127.0.0.1:8080
git config --global https.proxy https://127.0.0.1:8080

然后再git clone等命令就会自动走代理了。

如果要取消代理:

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

这里要说明一下,带参数是临时的,修改配置文件是永久变更,修改后最好重启所有 git bash 保证设置生效。

参考资料:
git如何设置使用代理


免责声明!

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



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