git如何设置使用代理
发表于:2022-04-07 |

使用命令直接设定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’

如果有问题,可以把单引号去掉试一下,并且将http和https代理都设置上试一下

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

vi ~/.gitconfig

新建或修改这两项配置

[http]

proxy = socks5://127.0.0.1:1080

[https]

proxy = socks5://127.0.0.1:1080

http/https代理

git config –global http.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 config -l –global

上一篇:
shell脚本判断端口是否打开
下一篇:
使用nginx反向代理jenkins