最近发现Github无法加载或不显示图片,严重影响日常使用。
查找资料并总结解决步骤如下:
更新:2021.01.11
1.Mac
修改 /etc/hosts 文件
修改host文件,将下面GitHub内容拷贝进去
####2.windows
修改 C:\Windows\System32\drivers\etc\hosts 文件
将下面GitHub内容拷贝进去,保存后按键盘Win+R
运行
ipconfig /flushdns
3.Linux
sudo vim /etc/hosts
/etc/init.d/ssh restart
输入密码后,点击 i键,进入Insert模式,将下面GitHub内容拷贝进去
#GitHub Start
140.82.114.4 github.com
140.82.113.4 gist.github.com
185.199.108.153 assets-cdn.github.com
199.232.96.133 raw.githubusercontent.com
199.232.96.133 gist.githubusercontent.com
199.232.96.133 cloud.githubusercontent.com
199.232.96.133 camo.githubusercontent.com
199.232.96.133 avatars.githubusercontent.com
199.232.96.133 avatars0.githubusercontent.com
199.232.96.133 avatars1.githubusercontent.com
199.232.96.133 avatars2.githubusercontent.com
199.232.96.133 avatars3.githubusercontent.com
199.232.96.133 avatars4.githubusercontent.com
199.232.96.133 avatars5.githubusercontent.com
199.232.96.133 avatars6.githubusercontent.com
199.232.96.133 avatars7.githubusercontent.com
199.232.96.133 avatars8.githubusercontent.com
#GitHub End
3.点击esc 键,然后输入:wq 保存退出即可。
4.再去打开或刷新Github页面,图片已经可以加载出来了。
备注:不熟悉终端操作步骤的可以将hosts文件拷贝到桌面,修改编辑好内容后再替换原来的hosts文件,替换是需要输入电脑密码
*快速一键安装
1.windows 另存bat
管理员身份运行
@echo off
echo “本脚本的作用为‘github’图片显示”
echo “请注意你的杀毒软件提示,请点击允许”
TIMEOUT /T 15
echo -------------------------------------------------
@xcopy C:\Windows\system32\drivers\etc\hosts C:\Windows\system32\drivers\etc\hosts.bak\ /d /c /i /y
echo hosts文件备份完毕,开始修改hosts文件。
TIMEOUT /T 5
echo ------------------------------------------------
@echo # GitHub Start >>C:\Windows\System32\drivers\etc\hosts
@echo 192.30.253.112 Build software better, together >>C:\Windows\System32\drivers\etc\hosts
@echo 192.30.253.119 gist.github.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 assets-cdn.github.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 raw.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 gist.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 cloud.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 camo.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 avatars0.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 avatars1.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 avatars2.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 avatars3.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 avatars4.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 avatars5.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 avatars6.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 avatars7.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo 151.101.184.133 avatars8.githubusercontent.com >>C:\Windows\System32\drivers\etc\hosts
@echo # GitHub End >>C:\Windows\System32\drivers\etc\hosts
echo hosts文件修改完成
@ipconfig /flushdns
echo ------------------------------------------------
echo “按任意键退出该脚本”
TIMEOUT /T 30
2.linux root
运行
echo "# GitHub Start" >> /etc/hosts;echo "192.30.253.112 Build software better, together" >> /etc/hosts;echo "192.30.253.119 gist.github.com" >> /etc/hosts;echo "151.101.184.133 assets-cdn.github.com" >> /etc/hosts;echo "151.101.184.133 raw.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 gist.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 cloud.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 camo.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 avatars0.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 avatars1.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 avatars2.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 avatars3.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 avatars4.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 avatars5.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 avatars6.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 avatars7.githubusercontent.com" >> /etc/hosts;echo "151.101.184.133 avatars8.githubusercontent.com" >> /etc/hosts;echo "# GitHub End" >> /etc/hosts ; /etc/init.d/ssh restart