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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM