One - One Code All

Blog Content

git clone速度太慢的解决办法

Linux-Mac   2020-04-05 16:05:20

最近发现使用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: 199.232.69.194

github.com的ip: 140.82.113.3


打开hosts文件

Windows上的hosts文件路径在C:\Windows\System32\drivers\etc\hosts

Linux的hosts文件路径在:sudo vim /etc/hosts


在hosts文件末尾添加两行(对应上面查到的ip)

199.232.69.194 github.global-ssl.fastly.net

140.82.113.3 github.com


保存更新DNS

Winodws系统的做法:打开CMD,输入ipconfig /flushdns

Linux的做法:在终端输入systemctl restart network.service



方法二:

nslook github.com

nslook github.global.ssl.fastly.net


把查出来的ip放到hosts, 重启网络服务。


方法三:


把原 URL 中的 github.com 替换为 github.com.cnpmjs.org,其余保持不变。

初次拉取完后,可以把url再换回来。

git clone -b develop https://github.com.cnpmjs.org/mygroup/commons.git
# git 查看远程仓库地址
git remote -v
# 修改远程仓库 
git remote rm origin
git remote add origin https://github.com/mygroup/commons.git
git branch --set-upstream-to=origin/develop develop



上一篇:java中判断空字符串和null的判断方法
下一篇:nginx kong missing password错误

The minute you think of giving up, think of the reason why you held on so long.