vpncloud.blog · 2026 中文机场评测、每 GB 透明计算与全平台客户端教程 更新日期:2026-12-02 · 14 家品牌 · 30 篇教程 · 100 篇文章
快速结论

Git 默认不区分系统代理:`https://` 仓库使用 `git config --global http.https://github.com.proxy http://127.0.0.1:7897` 精准加速;`git@github.com` SSH 仓库则需要在 `~/.ssh/config` 中配置 `ProxyCommand`。

详细配置步骤

1. 仅针对 GitHub 配置 HTTPS 代理(推荐)

执行 `git config --global http.https://github.com.proxy http://127.0.0.1:7897`(端口号按客户端实际端口调整),这样不会影响公司内网 Gitee/GitLab 直连。

2. 配置 SSH 走 SOCKS5/HTTP 代理

在 `~/.ssh/config` 添加:`Host github.com`、`Hostname ssh.github.com`、`Port 443`、`User git`,并在 Windows 使用 `ProxyCommand connect -S 127.0.0.1:7897 %h %p`(macOS/Linux 用 `nc -X 5 -x 127.0.0.1:7897 %h %p`)。

3. 测试 SSH 握手

运行 `ssh -T git@github.com`,看到 `Hi username! You've successfully authenticated` 即配置成功。

4. 取消全局 Git 代理方法

如需恢复直连,运行 `git config --global --unset http.https://github.com.proxy` 即可。

常见问题与排错技巧

  • 使用 `ssh.github.com` 的 443 端口穿透性优于默认 22 端口,配合 Clash 分流更稳。
  • 若客户端已开启 TUN 虚拟网卡模式且分流规则包含 GitHub,通常无需再手动配置上述步骤。

相关知识百科