小帅の技术博客 小帅の技术博客
首页
  • 基础
  • 框架
  • 进阶
  • 工程化
  • NodeJS
  • 脚本
  • 拓展
  • 技术
  • 服务器
程序猿
关于
友链
  • 分类
  • 标签
  • 归档
GitHub

前端小帅

学而不思则罔,思而不学则殆
首页
  • 基础
  • 框架
  • 进阶
  • 工程化
  • NodeJS
  • 脚本
  • 拓展
  • 技术
  • 服务器
程序猿
关于
友链
  • 分类
  • 标签
  • 归档
GitHub
  • NodeJs

  • 脚本

  • 拓展

  • 技术

    • 环境变量
    • Git常用命令
    • Github加速技巧
      • 一. 加速 (盘点提高国内访问 GitHub 的速度的 9 种方案)
        • 1. Github 镜像
        • 2. Github 文件加速
        • 3. Github 加速下载
        • 4. 加速你的 Github
        • 5. 谷歌浏览器插件
        • 6. Github raw 加速
        • 7. Github + Jsdelivr
        • 8. 通过 Gitee 中转 fork 仓库下载
        • 9. 通过修改 HOSTS 文件进行加速
        • 10. 通过修改 HOSTS 文件进行加速与图片加载失败问题
    • Npm包体积
  • 服务器

  • 全栈
  • 技术
sunss
2020-09-13

GitHub加速技巧

提示

收集、记录、整理一些 Github 相关使用技巧。

# 一. 加速 (盘点提高国内访问 GitHub 的速度的 9 种方案)

# 1. Github 镜像

# 比较常用的镜像地址

  • https://github.com.cnpmjs.org

  • https://hub.fastgit.org

# 使用方式

  • 正常 Github:git clone https://github.com/facebook/react.git
  • 镜像:git clone https://github.com.cnpmjs.org/facebook/react.git

# 总结

基本就是按照正常使用方式进行,只是把 Github 地址更换了一下,完全的镜像。 不过对于 publish 推送则不太行,不能正确的推送到 Github,不过我们只是下载倒没什么关系。

# 2. Github 文件加速

  • 利用 Cloudflare Workers 对 github release 、archive 以及项目文件进行加速,部署无需服务器且自带 CDN
  • 开源项目:gh-proxy——基于 cloudflare workers 的 GitHub 文件加速

# 3. Github 加速下载

  • 地址:http://toolwa.com/github/

# 4. 加速你的 Github

  • 地址:https://github.zhlh6.cn
  • 输入 Github 仓库地址,使用生成的地址进行 git ssh 等操作

# 5. 谷歌浏览器插件

GitHub加速

# 6. Github raw 加速

  • GitHub raw 域名并非 github.com 而是 raw.githubusercontent.com,上方的 GitHub 加速如果不能加速这个域名,那么可以使用 Static CDN 提供的反代服务。将 raw.githubusercontent.com 替换为 raw.staticdn.net 即可加速。

# 7. Github + Jsdelivr

  • jsdelivr 唯一美中不足的就是它不能获取 exe 文件以及 Release 处附加的 exe 和 dmg 文件。

# 8. 通过 Gitee 中转 fork 仓库下载

  • 网上有很多相关的教程,这里简要的说明下操作。

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

第一步

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

第二步

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

第二步

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

  • 手动把 cdn 和 ip 地址绑定。

  • 第一步:获取 github 的 global.ssl.fastly

地址访问:http://github.global.ssl.fastly.net.ipaddress.com/#ipinfo 获取 cdn 和 ip 域名:

第二步

得到:199.232.69.194 https://github.global.ssl.fastly.net

  • 第二步:获取 github.com 地址

访问:https://github.com.ipaddress.com/#ipinfo 获取 cdn 和 ip

第二步

得到:140.82.114.4 http://github.com

  • 第三步:修改 host 文件映射上面查找到的 IP

windows 系统:

① 修改 C:\Windows\System32\drivers\etc\hosts 文件的权限,指定可写入:右击->hosts->属性->安全->编辑->点击 Users->在 Users 的权限“写入”后面打勾,然后点击确定。如下:

第二步

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

199.232.69.194 github.global.ssl.fastly.net

140.82.114.4 github.com
1
2
3

刷新系统 dns 缓存:

用 WIN+R 快捷键打开运行窗口,输入命令:cmd 并回车进入命令行窗口。

接着输入命令:ipconfig /flushdns 回车后执行刷新本地 dns 缓存数据即可。

# 10. 通过修改 HOSTS 文件进行加速与图片加载失败问题

  • 可以通过该网站查询 Ip:https://www.ipaddress.com/
  • 前提:通过上面方法获取到了指定 Ip
  • 请打开 hosts 文件(C:\Windows\System32\drivers\etc) hosts,加上以下内容:
# 处理Github速度和图片加载失败问题

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

185.199.108.153 assets-cdn.github.com
185.199.109.153 assets-cdn.github.com
185.199.110.153 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com
#
199.232.68.133 raw.githubusercontent.com
199.232.68.133 gist.githubusercontent.com
199.232.68.133 cloud.githubusercontent.com
199.232.68.133 camo.githubusercontent.com
#
199.232.68.133 avatars0.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
199.232.68.133 avatars5.githubusercontent.com
199.232.68.133 avatars6.githubusercontent.com
199.232.68.133 avatars7.githubusercontent.com
199.232.68.133 avatars8.githubusercontent.com
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

总结:总的来说,如果只是简单的下载 GitHub 上他人的源码用于学习和研究,那么镜像下载基本满足需求了,也是比较快捷方便的。要是经常使用包括对图片有查看需求可以通过更改 host 实现效果。

编辑
#GitHub
上次更新: 2024/04/15, 14:35:14
Git常用命令
Npm包体积

← Git常用命令 Npm包体积→

最近更新
01
说说call、apply、bind是如何改变this的
03-29
02
从输入 URL 到页面加载完成发生了什么?
03-29
03
JavaScript进阶—— new 的执行过程
03-26
更多文章>
sunss | © 2020.08-2024.04 浙ICP备2022002957号-1
载入天数... 载入时分秒...  |  总访问量 次
提供CDN加速/云存储服务
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式