git clone 代码下载速度慢的解决方法

在https://www.ipaddress.com 查找 http://github.comhttp://global-ssl.fastly.Net 对应的IP地址,例如:
192.30.253.112 对应的 http://github.com
151.101.185.194 对应的 github.global.ssl.fastly.net
(这一步可能有差异)

Mac下:
打开文件路径/etc/hosts,将下列内容加入hosts文件后面:
192.30.253.112 github.com
151.101.185.194 github.global.ssl.fastly.net
151.101.184.249 global-ssl.fastly.net
185.199.111.153 assets-cdn.github.com
打开终端:输入以下内容,刷新DNS缓存:sudo dscacheutil -flushcache

Windows下:
用记事本打开hosts文件(路径在:C:\Windows\System32\drivers\etc\hosts)
将下列内容加入到hosts文件中:
192.30.253.112 github.com
151.101.185.194 github.global.ssl.fastly.net
151.101.184.249 global-ssl.fastly.net
185.199.111.153 assets-cdn.github.com
打开终端:输入以下内容,刷新DNS缓存:ipconfig /flushdns

完毕!(亲测mac下原本下载速度10K/s至200~300k/s)

猜你喜欢

转载自www.cnblogs.com/tristers/p/12172207.html