git clone速度太慢的解決辦法
在國內(nèi),你們肯定發(fā)現(xiàn)使用git clone的速度實(shí)在太慢,git clone的速度可能會(huì)讓你難以承受,現(xiàn)再次整理解決方法與大家分享,有圖有真相。
原因:git clone特別慢是因?yàn)間ithub.global.ssl.fastly.net域名被限制了。只要找到這個(gè)域名對(duì)應(yīng)的ip地址,然后在hosts文件中加上ip–>域名的映射,刷新DNS緩存便可。
適用各種操作系統(tǒng),本次測(cè)試系統(tǒng)為Ubuntu 18.04.2 LTS,下載速度從幾k提高到1M多。
沒有修改前git clone速度實(shí)在慢只有10K左右,如上圖。
修改后,git clone速度達(dá)到800多k?;蛘?M多。
1、查找域名對(duì)應(yīng)的ip地址,并修改hosts文件
linuxidc@linuxidc:~/linuxidc.com$ nslookup github.global.ssl.fastly.Net
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: github.global.ssl.fastly.Net
Address: 151.101.229.194
linuxidc@linuxidc:~/linuxidc.com$ nslookup github.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: github.com
Address: 13.229.188.59
如下圖:
然后修改hosts文件
Windows上的hosts文件路徑在
C:\Windows\System32\drivers\etc\hosts
Linux的hosts文件路徑在/etc/hosts中
sudo vim /etc/hosts
Mac的hosts文件路徑也在/etc/hosts中
sudo vi /etc/hosts
在hosts文件末尾添加兩行
github.com 13.229.188.59
github.global.ssl.fastly.Net 151.101.229.194
2、刷新DNS緩存
Linux:
sudo /etc/init.d/networking restart
Windows:
ipconfig /flushdns
Mac:
sudo killall -HUP mDNSResponder
以前的文章:git clone下載速度特慢的解決方案 https://www.linuxidc.com/Linux/2017-10/148116.htm