Git 客户端全局配置

如果你经常需要克隆 GitHub 上的开源项目,每次手动拼接 gh-proxy.org 会显得有些繁琐。通过 Git 原生的 insteadOf 机制,可以在本地自动将所有 GitHub 仓库请求重定向到加速代理。

一键配置命令

在终端中执行以下命令即可开启全局加速:

git config --global url."https://gh-proxy.org/https://github.com/".insteadOf "https://github.com/"

验证配置

配置完成后,你可以照常执行标准的 Git Clone 命令,底层会自动通过代理拉取:

git clone https://github.com/torvalds/linux.git

此时终端中请求将自动路由至 https://gh-proxy.org/https://github.com/torvalds/linux.git

取消配置

如果后续需要恢复直连,只需执行:

git config --global --unset url."https://gh-proxy.org/https://github.com/".insteadOf

💬 互动交流与反馈