亲测有效!两种方法彻底搞定 GitHub 下载慢、Clone 失败
还在为 GitHub clone 慢、下载 Releases 失败烦恼吗?分享两个一直在用的方法,简单直接,亲测有效。
方法一:修改 Hosts 文件(手动挡)
老方法,但依然管用。原理是跳过 DNS 解析,直接连上高速 IP。
获取 Hosts:直接去 https://github.com/521xueweihan/GitHub520 复制最新的 hosts 内容。
修改文件:把复制的内容粘贴到 hosts 文件末尾并保存。
macOS / Linux: /etc/hosts
Windows: C:\Windows\System32\drivers\etc\hosts (没权限就先拖到桌面改,再拖回去覆盖)
刷新 DNS:
Windows: ipconfig /flushdns
macOS: sudo killall -HUP mDNSResponder
Linux: sudo systemd-resolve --flush-caches
缺点: IP 会失效,变慢了就得重复第一步去更新。
方法二:使用反向代理(自动挡)
这个方法更省事,一劳永逸。网上这类公益代理服务很多,核心用法都是替换 URL。下面拿一个我常用的举例。
1. 加速 git clone
把 github.com 换成代理域名。
原始: git clone https://github.com/kubernetes/kubernetes.git
加速: git clone https://githubproxy.cc/kubernetes/kubernetes.git
2. 加速下载 Releases / 源码压缩包
在 github.com 前面加上代理域名和斜杠。
原始: https://github.com/Fndroid/clash_for_windows_pkg/releases/download/0.20.39/Clash.for.Windows-0.20.39-win.7z
加速: https://githubproxy.cc/github.com/Fndroid/clash_for_windows_pkg/releases/download/0.20.39/Clash.for.Windows-0.20.39-win.7z
3. 加速 Raw 文件
在 raw.githubusercontent.com 前面加上代理域名和斜杠。
原始: https://raw.githubusercontent.com/opa334/TrollStore/main/README.md
加速: https://githubproxy.cc/raw.githubusercontent.com/opa334/TrollStore/main/README.md
亲测有效的几个代理域名:
嫌麻烦的直接用方法二。下面这几个是我测试过,目前都还稳定好用的,挑个顺手的就行:
githubproxy.cc
ghproxylist.com
ghfast.top
gh-proxy.com