全面加速 GitHub,git clone 太慢的 9 种解决办法

#极限操作 2020-12-18 14:48:00 | 全文 1399 字,阅读约需 3 分钟 | 加载中... 次浏览

👋 相关阅读


GitHub 是通过 Git 进行版本控制的软件源代码托管服务平台

被戏称“同性”交友平台 gayhub

2018 年 6 月 4 日,微软宣布以 75 亿美元的股票收购 GitHub

GitHub 是我见过最豪横的平台

仓库不仅用于代码版本控制,也可以静态托管,甚至存储文件,永久链接等等

但是这么好的平台呢,速度却太慢(原因略),每当 clone,push,访问都是一件很头痛的事情,本文总结 9 种方法,解决烦恼。

为什么 GitHub 下载速度这么慢?

GitHub 在国内很多时候获取到的下载链接是亚马逊的服务器

想要加快 GitHub 下载速度就需要用到 GitHub 国内加速服务

GitHub 提速

1、GitHub 镜像访问

最常见 GitHub 镜像地址:

https://github.com.cnpmjs.org/ https://hub.fastgit.org/

访问上面的镜像网站,网站的内容跟 GitHub 是完整同步的镜像,然后在这个网站里面进行下载克隆等操作。

举个栗子: git clone https://github.com/mikecao/umami.git 替换为 git clone https://github.com.cnpmjs.org/mikecao/umami.git

2021.01.04 补充:

只需在 git clone 命令中将 gitclone.com 嵌入到克隆地址中即可

方法一(替换URL)

git clone https://gitclone.com/github.com/tendermint/tendermint.git`

方法二(设置git参数)

git config --global url."https://gitclone.com/".insteadOf https://
git clone https://github.com/tendermint/tendermint.git

方法三(使用cgit客户端)

cgit clone https://github.com/tendermint/tendermint.git

go get获取代码时,可以使用 goproxy.io 代理加速,用以下方法:

export GOPROXY=https://goproxy.io

然后正常go get即可 详情见官方文档 https://www.gitclone.com/docs/intro

2、GitHub 文件加速

使用非常简单,内有提示!

gh-proxy 开源项目:https://github.com/hunshcn/gh-proxy

演示: https://gh.api.99988866.xyz/ https://gh-proxy.edging.workers.dev/

3、Github 加速下载 Code ZIP

GitHub加速下载在线工具:http://toolwa.com/github/

使用方法:

  1. 进入 GitHub 某一项目主页
  2. 点击右侧的绿色按钮 “Code” > “Download ZIP”
  3. 等浏览器弹出下载框后复制下载框中的链接地址并粘贴到以上输入框
  4. 点击加速下载

4、加速链接 Github

GitHub 加速链接生成在线工具:https://github.zhlh6.cn/

使用方法:

输入 Github 仓库地址,使用生成的地址进行 git ssh 操作即可,

如:git clone 仓库的 ssh 地址

原理:利用 ucloud 提供的 GlobalSSH 功能,对 ssh 端口协议数据进行加速

5、谷歌浏览器GitHub加速插件(推荐)

插件直接下载安装:https://chrome.google.com/webstore/detail/github%E5%8A%A0%E9%80%9F/mfnkflidjnladnkldfonnaicljppahpg?hl=zh-CN

6、GitHub raw 链接加速

GitHub raw = raw.githubusercontent.com

raw.githubusercontent.com 替换为 raw.staticdn.net 即可加速。

7、GitHub + JsDelivr

JsDelivr CDN 只能加速仓库的静态文件

8、通过 Gitee 中转 fork 仓库下载

访问 gitee 网站: https://gitee.com/ 并登录,在右上角顶部选择“从 GitHub/GitLab 导入仓库”

在导入页面中粘贴你的 Github 仓库地址,点击导入即可

等待导入操作完成,然后在导入的仓库中下载浏览对应的该 GitHub 仓库代码,你也可以点击仓库顶部的“刷新”按钮进行 Github 代码仓库的同步。

9、通过修改 HOSTS 文件进行加速

手动把 CDNip 和域名地址绑定。

1、访问:http://github.global.ssl.fastly.net.ipaddress.com/#ipinfo 获取 CDNip 和域名

eg:199.232.69.194 https://github.global.ssl.fastly.net

2、访问:https://github.com.ipaddress.com/#ipinfo 获取 CDNip 和域名

eg:140.82.114.4 http://github.com

3、修改本地 host 文件映射上面查找到的 IP

3.1、修改 C:WindowsSystem32driversetchosts 文件的权限,指定可写入:

右击->hosts->属性->安全->编辑->点击Users->在Users的权限“写入”后面打勾。

3.2、右击->hosts->打开方式->选定记事本(或者你喜欢的编辑器)->在末尾处添加以下内容:

199.232.69.194 github.global.ssl.fastly.net
140.82.114.4 github.com

via: https://www.tsingsea.com/git-clone-speed-up.html

Edit | Last updated on 2024-04-21 11:10:27




×