1. 设置 HTTP/HTTPS 代理(全局)
1 2 3 4 5
| git config --global http.proxy http://127.0.0.1:10808
git config --global https.proxy http://127.0.0.1:10808
|
💡 大多数情况下,只设置 http.proxy 即可,因为 Git 的 HTTPS 流量也通过 HTTP CONNECT 隧道传输。
2. 设置 SOCKS5 代理(如 Clash、V2Ray)
1 2 3
| git config --global http.proxy socks5://127.0.0.1:10808
git config --global http.proxy socks5h://127.0.0.1:10808
|
🔹 socks5://:本地解析域名(可能泄露 DNS)
🔹 socks5h://:远程解析域名(更安全,防止 DNS 污染)
3. 查看当前 Git 代理配置:
1 2
| git config --global --get http.proxy git config --global --get https.proxy
|
4. 取消代理:
1 2
| git config --global --unset http.proxy git config --global --unset https.proxy
|