Github加速的10种方式

一、 dev-sidecar- 强烈推荐

开发者边车,命名取自service-mesh的service-sidecar,意为为开发者打辅助的边车工具 通过本地代理的方式将https请求代理到一些国内的加速通道上

1 下载安装包

Windows: 请选择DevSidecar-x.x.x.exe Mac: 请选择DevSidecar-x.x.x.dmg Ubuntu: 请选择DevSidecar-x.x.x.deb 其他linux: 请选择DevSidecar-x.x.x.AppImage (未做测试,不保证能用)

linux安装说明请参考 linux安装文档

注意:由于没有买应用证书,所以应用在下载安装时会有“未知发行者”等安全提示,选择保留即可。

2 安装后打开

注意:mac版安装需要在“系统偏好设置->安全性与隐私->通用”中解锁并允许应用安装

img

3 安装根证书

第一次打开会提示安装证书,根据提示操作即可

更多有关根证书的说明,请参考 为什么要安装根证书?

根证书是本地随机生成的,所以不用担心根证书的安全问题(本应用不收集任何用户信息) 你也可以在加速服务设置中自定义根证书(PEM格式的证书与私钥)

火狐浏览器需要手动安装证书

4 开始加速吧

去试试打开github


第一次访问会去国外的dns服务器上获取ip,会比较慢一点,后面就快了


开启前 vs 开启后

 开启前开启后
头像 img img
clone img img
zip 下载 img img秒下的,实在截不到速度的图

二、GitHub 镜像访问

这里提供两个最常用的镜像地址:

也就是说上面的镜像就是一个克隆版的 GitHub,你可以访问上面的镜像网站,网站的内容跟 GitHub 是完整同步的镜像,然后在这个网站里面进行下载克隆等操作

三、GitHub 文件加速

利用 Cloudflare Workers 对 github release 、archive 以及项目文件进行加速,部署无需服务器且自带CDN.

以上网站为演示站点,如无法打开可以查看开源项目:gh-proxy-GitHub(https://hunsh.net/archives/23/) 文件加速自行部署。

四、 Github 加速下载

只需要复制当前 GitHub 地址粘贴到输入框中就可以代理加速下载!

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

image-20211104000400332

五、 加速你的 Github

https://github.zhlh6.cn

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

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

image-20211104000714469

如果小伙伴在线安装不便,可以加我微信号:codedq 我免费发给大家!

 

七、 GitHub raw 加速

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

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

八、 GitHub + Jsdelivr

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

也就是说如果 exe 文件是附加在 Release 处但是没有在 code 里面的话是无法获取的。所以只能当作静态文件 cdn 用途,而不能作为 Release 加速下载的用途。

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

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

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

image-20211104001227583

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

手动把cdn和ip地址绑定。

10.1 获取需要绑定地址

image-20211104002141778

  • 需要查询的地址

     # 基本地址
     'github.com',
     'gist.github.com',
     'assets-cdn.github.com',
     'raw.githubusercontent.com',
     'gist.githubusercontent.com',
     'cloud.githubusercontent.com',
     'camo.githubusercontent.com',
     'avatars0.githubusercontent.com',
     'avatars1.githubusercontent.com',
     'avatars2.githubusercontent.com',
     'avatars3.githubusercontent.com',
     'avatars4.githubusercontent.com',
     'avatars5.githubusercontent.com',
     'avatars6.githubusercontent.com',
     'avatars7.githubusercontent.com',
     'avatars8.githubusercontent.com',
     'avatars.githubusercontent.com',
     'github.githubassets.com',
     'user-images.githubusercontent.com',
     'codeload.github.com',
     'favicons.githubusercontent.com',
     'api.github.com'

     

  • 通过python脚本获取地址

     #!/usr/bin/env python
     # coding:utf-8
     
     import socket
     
     def output_hosts():
         domains = ['github.com',
                     'gist.github.com',
                     'assets-cdn.github.com',
                     'raw.githubusercontent.com',
                     'gist.githubusercontent.com',
                     'cloud.githubusercontent.com',
                     'camo.githubusercontent.com',
                     'avatars0.githubusercontent.com',
                     'avatars1.githubusercontent.com',
                     'avatars2.githubusercontent.com',
                     'avatars3.githubusercontent.com',
                     'avatars4.githubusercontent.com',
                     'avatars5.githubusercontent.com',
                     'avatars6.githubusercontent.com',
                     'avatars7.githubusercontent.com',
                     'avatars8.githubusercontent.com',
                     'avatars.githubusercontent.com',
                     'github.githubassets.com',
                     'user-images.githubusercontent.com',
                     'codeload.github.com',
                     'favicons.githubusercontent.com',
                     'api.github.com'
                    ]
         
         with open('hosts.txt', 'w') as f:
             f.write('```\n')
             f.write('# GitHub Start \n')
             for domain in domains:
                 print('Querying ip for domain %s'%domain)
                 ip = socket.gethostbyname(domain)
                 print(ip)
                 f.write('%s %s\n'%(ip, domain))
             f.write('# GitHub End \n')
             f.write('```\n')
             
             
         
     if __name__ == '__main__':
         output_hosts()
     

    执行python脚本,获取如下文本

     # GitHub Start 
     140.82.121.3 github.com
     140.82.121.3 gist.github.com
     185.199.110.153 assets-cdn.github.com
     185.199.108.133 raw.githubusercontent.com
     185.199.111.133 gist.githubusercontent.com
     185.199.110.133 cloud.githubusercontent.com
     185.199.111.133 camo.githubusercontent.com
     185.199.111.133 avatars0.githubusercontent.com
     185.199.110.133 avatars1.githubusercontent.com
     185.199.111.133 avatars2.githubusercontent.com
     185.199.109.133 avatars3.githubusercontent.com
     185.199.108.133 avatars4.githubusercontent.com
     185.199.111.133 avatars5.githubusercontent.com
     185.199.109.133 avatars6.githubusercontent.com
     185.199.109.133 avatars7.githubusercontent.com
     185.199.110.133 avatars8.githubusercontent.com
     185.199.108.133 avatars.githubusercontent.com
     185.199.111.154 github.githubassets.com
     185.199.109.133 user-images.githubusercontent.com
     140.82.112.9 codeload.github.com
     185.199.110.133 favicons.githubusercontent.com
     192.30.255.116 api.github.com
     # GitHub End

     

10.2 host 文件映射

具体操作可参考:GitHub-Host加速

  1. Windows系统:修改C:\Windows\System32\drivers\etc\hosts文件

     # 网络刷新
     ipconfig /flushdns

    image-20211104003316503

  2. Linux系统:修改C:\Windows\System32\drivers\etc\hosts文件

     # 网络刷新
     systemctl restart network
posted @ 2021-11-04 00:51  灬丨嘎嘣脆丨灬  阅读(16041)  评论(0编辑  收藏  举报