31

访问github下载较慢的问题

 4 years ago
source link: https://www.wencst.com/archives/1905
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

环境

mac

中国移动网络

问题

在mac上执行git pull命令,从github下载代码非常慢,有时候只有几kb,有时候就卡死不动了。在命令行ping github.com时,发现访问的居然是国外的IP,所以很有可能被墙了。

解决

1.首先打开hosts文件

mac/linux地址如下:

sudo vim /etc/hosts

windows地址是

C:\Windows\System32\drivers\etc\HOSTS

2.浏览器访问https://www.ipaddress.com/地址

在地址中输入 github.comgithub.global.ssl.fastly.net 以获取对应的ip。

3.将浏览器中获取到的IP写入hosts文件

4.刷新使得立即生效

mac生效方法:

sudo killall -HUP mDNSResponder

windows生效方法:

ipconfig /flushdns
// 如果执行失败,则打开services.msc,启动服务<strong>dns client</strong>后再执行上述命令

linux生效方法:

<code>systemctl restart </code>network<code>
systemctl restart nscd 
//两个命令选其一,第二个命令需要先安装nscd服务

</code>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK