- 设置 HTTP 代理
可以使用以下命令设置 HTTP 代理:
git config --global http.proxy http://proxy.example.com:8080
其中,http://proxy.example.com:8080
是你的代理服务器地址和端口号。如果代理需要认证,可以在 URL 中添加用户名和密码:
git config --global http.proxy http://username:password@proxy.example.com:8080
- 设置 HTTPS 代理
同样地,你也可以使用以下命令设置 HTTPS 代理:
git config --global https.proxy https://proxy.example.com:8080
如果代理需要认证,可以在 URL 中添加用户名和密码:
git config --global https.proxy https://username:password@proxy.example.com:8080
- 取消代理
如果你想取消代理,可以使用以下命令:
git config --global --unset http.proxy
git config --global --unset https.proxy