一鍵解決git clone慢的問題
阿新 • • 發佈:2021-02-12
技術標籤:gitgithubdns伺服器opensource
問題
國內使用git clone
命令或者連線github網站時速度特別慢,其原因是github的相關域名遭到了DNS汙染。
解決思路
在http://tool.chinaz.com
搜尋github/gitlab等相關域名指向連線速度最快的IP地址,將其配置到本機的DNS配置檔案。
解決效果
以deck.gl為例,速度提升到184K每秒,使用前不到10K每秒。
嫌麻煩一鍵解決
為了方便配置,我將整個配置過程編寫成了一個自動化軟體,直接執行即可,原始碼託管在github。
- 下載gitfree。
- 如果你是WINDOWS使用者,直接右擊使用管理員許可權執行即可。
- 如果你是LINUX/MACOS使用者,直接進入gitfree所在資料夾,以管理員許可權執行即可:
sudo ./gitfree
- 原DNS配置檔案會自動備份在gitfree所在目錄下。
不嫌麻煩手動解決
- 登入
http://tool.chinaz.com
,搜尋github.com gitlab等域名,記錄下對應的速度最快的IP地址。 - 在本機的DNS配置檔案最後新增對應配置。
- windows路徑:C:\Windows\System32\drivers\etc\hosts
- linux/macos路徑:/etc/hosts
- 修改前記得備份。
# ...... # 原來的配置資訊 172.65.251.78 gitlab.com 52.74.223.119 github.com 185.199.109.154 github.githubassets.com 185.199.109.133 avatars8.githubusercontent.com 185.199.109.133 avatars7.githubusercontent.com 185.199.109.133 avatars6.githubusercontent.com 185.199.108.133 avatars5.githubusercontent.com 185.199.110.133 avatars4.githubusercontent.com 185.199.109.133 avatars3.githubusercontent.com 185.199.111.133 avatars2.githubusercontent.com 185.199.109.133 avatars1.githubusercontent.com 185.199.109.133 avatars0.githubusercontent.com 185.199.111.133 avatars0.githubusercontent.com 185.199.111.133 avatars0.githubusercontent.com 185.199.108.133 avatars0.githubusercontent.com 185.199.108.133 avatars0.githubusercontent.com 185.199.108.133 avatars0.githubusercontent.com 185.199.111.133 avatars.githubusercontent.com 185.199.111.133 avatars.githubusercontent.com 31.13.81.17 github.global.ssl.fastly.net 185.199.108.133 camo.githubusercontent.com 185.199.108.133 cloud.githubusercontent.com 185.199.110.133 gist.githubusercontent.com 0.0.0.0 raw.githubusercontent.com 185.199.108.153 assets-cdn.github.com
附錄——需要搜尋的域名
- gitlab.com
- github.com
- github.githubassets.com
- avatars8.githubusercontent.com
- avatars7.githubusercontent.com
- avatars6.githubusercontent.com
- avatars5.githubusercontent.com
- avatars4.githubusercontent.com
- avatars3.githubusercontent.com
- avatars2.githubusercontent.com
- avatars1.githubusercontent.com
- avatars0.githubusercontent.com
- avatars0.githubusercontent.com
- avatars0.githubusercontent.com
- avatars0.githubusercontent.com
- avatars0.githubusercontent.com
- avatars0.githubusercontent.com
- avatars.githubusercontent.com
- avatars.githubusercontent.com
- github.global.ssl.fastly.net
- camo.githubusercontent.com
- cloud.githubusercontent.com
- gist.githubusercontent.com
- raw.githubusercontent.com
- assets-cdn.github.com