要设置 Git 代理,请使用以下命令:

  1. 在命令行中输入以下命令以设置 HTTP 代理:
git config --global http.proxy http://proxy.example.com:8080

将'proxy.example.com'替换为您的代理服务器的主机名或 IP 地址,并将'8080'替换为代理服务器的端口号。

  1. 在命令行中输入以下命令以设置 HTTPS 代理:
git config --global https.proxy https://proxy.example.com:8080

将'proxy.example.com'替换为您的代理服务器的主机名或 IP 地址,并将'8080'替换为代理服务器的端口号。

  1. 如果您需要使用身份验证来连接代理服务器,请在命令行中输入以下命令:
git config --global http.proxyAuthMethod 'basic'
git config --global http.proxyAuthUsername 'your_username'
git config --global http.proxyAuthPassword 'your_password'
git config --global https.proxyAuthMethod 'basic'
git config --global https.proxyAuthUsername 'your_username'
git config --global https.proxyAuthPassword 'your_password'

将'your_username'和'your_password'替换为您的代理服务器的用户名和密码。

  1. 如果您需要取消代理设置,请在命令行中输入以下命令:
git config --global --unset http.proxy
git config --global --unset https.proxy

这将从配置文件中删除代理设置。

如何设置 Git 代理