最近發現使用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
- 打開hosts文件
- Windows上的hosts文件路徑在
C:\Windows\System32\drivers\etc\hosts
- Linux的hosts文件路徑在:
sudo vim /etc/hosts
- 在hosts文件末尾添加兩行(對應上面查到的ip)
151.101.185.194 github.global-ssl.fastly.net 192.30.253.112 github.com
- 保存更新DNS
- Winodws系統的做法:打開CMD,輸入
ipconfig /flushdns
- Linux的做法:在終端輸入
sudo /etc/init.d/networking restart
- 完成,試試
git clone
這條命令速度如何?