https://www.jianshu.com/p/e491fa215fb2
最近想用Mac电脑访问github发现一直登不上去,在命令行终端ping www.github.com也是超时,以前访问github是没有问题的,不知道出了什么问题,于是各种百度。最后找到了一个解决方案:
1.新建一个访达窗口,同时按住shift command G三个键,进入前往文件夹页面
![](https://upload-images.jianshu.io/upload_images/4114308-443c2e6b16cb0b50.png?imageMogr2/auto-orient/strip|imageView2/2/w/598)
2.在输入框内输入/etc/hosts
![](https://upload-images.jianshu.io/upload_images/4114308-447adeb4ed9c9e54.png?imageMogr2/auto-orient/strip|imageView2/2/w/603)
3.找到hosts文件夹
![](https://upload-images.jianshu.io/upload_images/4114308-ab1e6c453de7c809.png?imageMogr2/auto-orient/strip|imageView2/2/w/223)
4.由于hosts文件夹不可编辑,所以复制一份hosts文件先保存到本地桌面
5.在新的hosts文件夹里输入如下代码:
# End of section http://github.com 204.232.175.94 http://gist.github.com 107.21.116.220 http://help.github.com 207.97.227.252 http://nodeload.github.com 199.27.76.130 http://raw.github.com 107.22.3.110 http://status.github.com 204.232.175.78 http://training.github.com 207.97.227.243 http://www.github.com
![](https://upload-images.jianshu.io/upload_images/4114308-c9768a5cb14d3379.png?imageMogr2/auto-orient/strip|imageView2/2/w/578)
然后点击保存。
6.将/etc/hosts原来的文件删除,删除的时候需要输入你的电脑开机密码
7.再将修改后的保存到桌面的hosts文件拖拽到/etc文件夹下,期间有可能需要你输入开机密码,文件名最好是hosts
8.以上完成后,我们来到终端命令行ping 一下github
![](https://upload-images.jianshu.io/upload_images/4114308-ad717085a9accdc8.png?imageMogr2/auto-orient/strip|imageView2/2/w/471)
发现可以ping通了,终于不再超时了,这时无法按耐住心中的喜悦了
9.接下来我们来浏览器里最终检测下是否可以访问github
发现终于可以了,见到了久违的界面
![](https://upload-images.jianshu.io/upload_images/4114308-1fbddbcd978c644c.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200)
至此,mac电脑无法访问github的问题终于得到了解决
在此也感谢网上一些大佬的支持,参考链接https://www.cnblogs.com/hankleo/p/13563074.html