參考:https://www.jianshu.com/p/3f6477049ece
最近發現使用git clone的速度比較慢,於是找到了辦法分享給大家:
思路:
git clone特別慢是因爲github.global.ssl.fastly.net
域名被限制了。
只要找到這個域名對應的ip地址,然後在hosts文件中加上ip–>域名的映射,刷新DNS緩存便可。
實施:
- 在網站 https://www.ipaddress.com/ 分別搜索:
github.global.ssl.fastly.net
github.com
得到ip:
github.global.ssl.fastly.net的ip
github.com的ip
2、打開hosts文件
- Windows上的hosts文件路徑在
C:\Windows\System32\drivers\etc\hosts
- Linux的hosts文件路徑在:
sudo vim /etc/hosts
- hosts文件末尾添加兩行(對應上面查到的ip)
3、在hosts文件末尾添加兩行(對應上面查到的ip)
151.101.185.194 github.global-ssl.fastly.net
192.30.253.112 github.com
4、保存更新DNS
Winodws系統的做法:打開CMD,輸入ipconfig /flushdns
Linux的做法:在終端輸入sudo /etc/init.d/networking restart
5、完成,試試git clone
這條命令速度如何?
體驗
總的來說是有一點改善的,從開始的十幾Kb的速度變成了五十多Kb