方式一:替换克隆地址(最简单)
打开首页工具,粘贴仓库链接,或直接粘贴整条 git clone 命令,拿到加速地址后:
git clone https://gh-proxy.com/https://github.com/user/repo.git
方式二:全局自动加速(推荐)
一次配置,之后所有 git clone / fetch / pull 自动走加速节点:
git config --global url."https://gh-proxy.com/https://github.com/".insteadOf "https://github.com/"
撤销恢复直连:
git config --global --unset url."https://gh-proxy.com/https://github.com/".insteadOf
注意:insteadOf 对 git push 也会生效,但镜像节点不接受推送。需要推送时改用 SSH 远端,或先执行上面的 unset 命令。
方式三:浅克隆提速
git clone --depth=1 https://gh-proxy.com/https://github.com/user/repo.git
--depth=1 只拉取最新一次提交,配合 --single-branch 更快。之后需要完整历史时执行:
git fetch --unshallow
冷门仓库首次克隆很慢?
前缀代理节点一般直接透传、无需预热;若某节点响应慢或失败,换结果列表中的其他节点重试,或用首页「节点测速」挑最快的。