解决GitHub中头像显示异常、设置不了头像、README图片无法显示等问题

解决GitHub中头像显示异常、设置不了头像、README图片无法显示等问题

  很多时候在访问 GitHub 官网时容易出现 GitHub 头像显示异常的问题。虽然这个问题无关痛痒,不过对于有强迫症的人来说非解决不可。也有时候居然在设置中编辑不了头像(编辑头像的窗体一直加载不出。笔者曾经尝试让电脑加载一晚上,但是第二天醒来,发现编辑头像的窗体还在显示正在加载的转圈动画,真是不能忍了)。解决的办法也很简单。

  头像显示异常、设置不了头像、README.md 中的图片显示裂图等问题是解析外国网站域名超时所导致的。我们可以通过进行域名重定向来解决。域名重定向可以跳过对域名的解析而直接访问其IP,这样能尽量避免超时。

  域名重定向在文件 hosts(文件 hosts 位于 C:\Windows\System32\drivers\etc)里配置来实现。以文本方式打开文件 hosts(注意:文件 hosts 是一个没有文件后缀的文件,不是文件 hosts.txt),在其添加以下内容:

# GitHub 开始 

此右侧域名的IP    github.com 
此右侧域名的IP    gist.github.com
此右侧域名的IP    assets-cdn.github.com
此右侧域名的IP    raw.githubusercontent.com
此右侧域名的IP    gist.githubusercontent.com
此右侧域名的IP    cloud.githubusercontent.com
此右侧域名的IP    camo.githubusercontent.com
此右侧域名的IP    avatars.githubusercontent.com
此右侧域名的IP    avatars0.githubusercontent.com
此右侧域名的IP    avatars1.githubusercontent.com
此右侧域名的IP    avatars2.githubusercontent.com
此右侧域名的IP    avatars3.githubusercontent.com
此右侧域名的IP    avatars4.githubusercontent.com
此右侧域名的IP    avatars5.githubusercontent.com
此右侧域名的IP    avatars6.githubusercontent.com
此右侧域名的IP    avatars7.githubusercontent.com
此右侧域名的IP    avatars8.githubusercontent.com
此右侧域名的IP    media.githubusercontent.com

# GitHub 结束

  其中,“此右侧域名的 IP”部分需要你自己将右侧域名的正确 IP 换上。而域名可以通过在页面代码(页面代码可以在浏览器中的“开发人员工具”中查看)中获取(光标在页面代码中移动可以定位图片的域名)。那么,如何知道右侧域名的正确 IP 呢?可以通过IP查询网站: https://www.ipaddress.com/ 。使用此网站解析域名后,将 IP 替换到上述文本的相应的内容即可。另外要注意,域名的 IP 有可能以后会变化,因此要及时更新 hosts 文件的内容,否则以后某天 GitHub 官网会打不开。

  最后在 CMD 中输入此命令 ipconfig /flushdns 来刷新 DNS 缓存,从而使上述文件 hosts 中的配置生效。


【附】一些关于 ipconfig 的命令:

  • 刷新 DNS 缓存:ipconfig /flushdns

  • 显示 DNS 缓存:ipconfig /displaydns

  • 使用 DHCP 协议更新 IP:ipconfig /renew


  截止到 2022 年 4 月 24 日,上述的域名解析结果为:

# GitHub 开始 

140.82.114.3    github.com 
140.82.114.4    gist.github.com
185.199.108.153   assets-cdn.github.com
185.199.108.133    raw.githubusercontent.com
185.199.108.133    gist.githubusercontent.com
185.199.108.133    cloud.githubusercontent.com
185.199.108.133    camo.githubusercontent.com
185.199.108.133    avatars.githubusercontent.com
185.199.108.133    avatars0.githubusercontent.com
185.199.108.133    avatars1.githubusercontent.com
185.199.108.133    avatars2.githubusercontent.com
185.199.108.133    avatars3.githubusercontent.com
185.199.108.133    avatars4.githubusercontent.com
185.199.108.133    avatars5.githubusercontent.com
185.199.108.133    avatars6.githubusercontent.com
185.199.108.133    avatars7.githubusercontent.com
185.199.108.133    avatars8.githubusercontent.com
185.199.108.133    media.githubusercontent.com
 
# GitHub 结束

  另外,使用 IP 查询网站 https://www.ipaddress.com/ 查询上述 IP 的快捷查询网址为:

待查询网址快捷查询网址
github.comhttps://github.com.ipaddress.com/
gist.github.comhttps://github.com.ipaddress.com/gist.github.com
assets-cdn.github.comhttps://github.com.ipaddress.com/assets-cdn.github.com
raw.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/raw.githubusercontent.com
gist.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/gist.githubusercontent.com
cloud.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/cloud.githubusercontent.com
camo.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/camo.githubusercontent.com
avatars.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars.githubusercontent.com
avatars0.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars0.githubusercontent.com
avatars1.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars1.githubusercontent.com
avatars2.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars2.githubusercontent.com
avatars3.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars3.githubusercontent.com
avatars4.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars4.githubusercontent.com
avatars5.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars5.githubusercontent.com
avatars6.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars6.githubusercontent.com
avatars7.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars7.githubusercontent.com
avatars8.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/avatars8.githubusercontent.com
media.githubusercontent.comhttps://githubusercontent.com.ipaddress.com/media.githubusercontent.com
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值