GitHub 不显示图片 Mac/Windows解决

更新于: 2021

原因:DNS污染或其他原因导致域名不能解析到ip
解决方案:直接添加域名映射ip即可

一.Mac 环境下:

第1步:终端输入 sudo vi /etc/hosts 后 输入密码

第2步:按i进入INSERT模式,拷贝下方内容放到最下面一个~

# GitHub Start
140.82.114.4 github.com
140.82.114.4 gist.github.com
185.199.108.153 assets-cdn.github.com
151.101.64.133 raw.githubusercontent.com
151.101.184.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.184.133 camo.githubusercontent.com
151.101.184.133 avatars0.githubusercontent.com
151.101.184.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.184.133 avatars3.githubusercontent.com
151.101.184.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.184.133 avatars8.githubusercontent.com 
# GitHub End

按下i后把光标移动到最后再按下回车即可另起一行,command + v粘贴上面的内容即可,截图只是示意,这个解析的ip有时候会改变,虽然也能ping通,但是不能加载出图片

输入内容

第3步:点击esc键,再输入:wq保存退出,刷新页面即可看到效果。

也可以将此文件拷贝桌面后修改,改完后覆盖放回。

二.Windows 环境下:

第1步:找到C:\Windows\System32\drivers\etc\hosts打开

第2步:加入上述内容在末尾,保存刷新网页即可

三.终极解决方案

如果以上操作还是不行,说明域名解析的ip仍是不对,那就需要我们自己去找了,以Chrome为例,按F12打开控制台,点开元素审查,选择图片,会看到图片的url,拿到域名后在域名解析网站上进行解析,就能获取到真正的ip地址,此时,将其按照上述方式加到host文件中即可。

GitHub用的好,代码从此没烦恼

你可能感兴趣的:(GitHub 不显示图片 Mac/Windows解决)