解决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 /flushdns
-
使用 DHCP 協議更新 IP:ipconfig /renew
??截止到 2021 年 3 月 10 日,上述的域名解析結果為:
# GitHub 開始 140.82.113.4 github.com 140.82.114.3 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.com | https://github.com.ipaddress.com/ |
| gist.github.com | https://github.com.ipaddress.com/gist.github.com |
| assets-cdn.github.com | https://github.com.ipaddress.com/assets-cdn.github.com |
| raw.githubusercontent.com | https://githubusercontent.com.ipaddress.com/raw.githubusercontent.com |
| gist.githubusercontent.com | https://githubusercontent.com.ipaddress.com/gist.githubusercontent.com |
| cloud.githubusercontent.com | https://githubusercontent.com.ipaddress.com/cloud.githubusercontent.com |
| camo.githubusercontent.com | https://githubusercontent.com.ipaddress.com/camo.githubusercontent.com |
| avatars.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars.githubusercontent.com |
| avatars0.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars0.githubusercontent.com |
| avatars1.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars1.githubusercontent.com |
| avatars2.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars2.githubusercontent.com |
| avatars3.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars3.githubusercontent.com |
| avatars4.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars4.githubusercontent.com |
| avatars5.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars5.githubusercontent.com |
| avatars6.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars6.githubusercontent.com |
| avatars7.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars7.githubusercontent.com |
| avatars8.githubusercontent.com | https://githubusercontent.com.ipaddress.com/avatars8.githubusercontent.com |
| media.githubusercontent.com | https://githubusercontent.com.ipaddress.com/media.githubusercontent.com |
總結
以上是生活随笔為你收集整理的解决GitHub中头像显示异常、设置不了头像、README图片无法显示等问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java 语法规定之外的命名注释规范
- 下一篇: Java官方相关资源文件的获取教程