本文最后更新于 548 天前,其中的信息可能已经有所发展或是发生改变。
由于大陆网络环境问题,GitHub处于半被墙状态。但作为程序员,GitHub是犹如生命之水的存在。那么当我们需要clone一个仓库时,就会发现,速度从几十kb/s掉到几kb/s。如果是小型的项目,那么等几分钟无伤大雅,当大项目降临时,这个速度要等到猴年马月啊!
FastGit
FastGit 是一个对于 GitHub.com 的镜像加速器。我们使用开放资源为 GitHub 加速。
关于 FastGit 的使用,本质上与 git
有关。常规的面向 GitHub 的 clone
命令可能如下:
git clone https://github.com/author/repo
使用 FastGit 时,可使用如下命令:
git clone https://hub.fastgit.org/author/repo
正如您所见, FastGit 仅仅是 GitHub 的代理,所以我们仅需要替换远程地址。
当然,您也可以直接修改 git
的配置,使用 FastGit 替换所有指向 GitHub 的链接:
git config --global url."https://hub.fastgit.org/".insteadOf "https://github.com/"
git config protocol.https.allow always
对于正常的 clone
, push
操作,FastGit 已经提供了相当完善的操作。对于 Release 和源码存档的下载,我们可以使用如下方法进行操作。
# Release
# 假设下载链接为 https://github.com/A/A/releases/download/1.0/1.0.tar.gz
wget https://download.fastgit.org/A/A/releases/download/1.0/1.0.tar.gz
# Codeload
# 假设下载链接为 https://hub.fastgit.org/A/A/archive/master.zip
# 或者 https://codeload.github.com/A/A/zip/master
wget https://download.fastgit.org/A/A/archive/master.zip
目前我们的 SSH 克隆地址为 ssh.fastgit.org。只需要修正地址即可完成加速。
我们同样对https://raw.githubusercontent.com/进行了代理,地址为https://raw.fastgit.org/。
大功告成!
本文章引用自FastGit文档:https://doc.fastgit.org/zh-cn/