git clone 下載速度慢的解決方法
- 在https://www.ipaddress.com 查找
http://github.com
和http://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
文件; -
將下列內容加入到拷貝出的
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
-
用拷貝出的文件替換
hosts
文件; -
打開終端:輸入以下內容,刷新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