1.5 KiB
1.5 KiB
title, type, tags
| title | type | tags | |||||
|---|---|---|---|---|---|---|---|
| Git HTTP/SOCKS5 代理配置 | concept |
|
Definition
Git 代理配置是通过 git config --global http.proxy 和 git config --global https.proxy 全局设置,让 Git 的 HTTP/HTTPS/SSH 操作通过本地代理服务器进行。
Commands
HTTP 代理
git config --global http.proxy http://127.0.0.1:10809
git config --global https.proxy http://127.0.0.1:10809
SOCKS5 代理(速度通常更快)
git config --global http.proxy socks5://127.0.0.1:10808
git config --global https.proxy socks5://127.0.0.1:10808
取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
查看当前配置
git config --global --get http.proxy
Core Insight
设置代理后,Git 的所有网络流量通过本地代理转发。GFW 只能看到通向本地代理的连接,无法识别目标域名,从根本上规避 TCP RST 攻击。
Scope
- 全局(
--global):影响当前用户所有 Git 仓库 - 本地(无
--global):仅影响当前仓库 - 仅影响 Git 命令,不影响终端其他程序
Relationship to Other Concepts
- TCP RST 攻击 ← solves:代理让 GFW 无法检测 GitHub 域名
- SOCKS5 代理 ← transport_layer:SOCKS5 比 HTTP 代理更底层,支持更多协议
- V2RayN ← provides:V2RayN 同时提供 HTTP 和 SOCKS5 代理端口