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 config -l --global

 
 
原文地址:https://www.cnblogs.com/john-xiong/p/14733774.html