git相关的代理配置

发布时间 2023-05-10 11:39:40作者: codeRhythm

1 配置代理

git config --global http.proxy http://<username>:<password>@<proxy.server.com>:<8080>
git config --global https.proxy http://<username>:<password>@<proxy.server.com>:<8080>

2 替换git协议为https协议

在很多企业的内网,防火墙会屏蔽git://协议的访问请求,如果git://无法访问,可尝试更换为https://协议

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

3 取消https协议的证书验证

在有些企业访问外网的代理,会强行把https的证书进行替换,导致https访问时,出现证书错误。如果想跳过证书错误,需要把git全局的证书验证关闭。

git config --global http.sslVerify false