Github,全球最大的開源社區,想必大家都非常熟悉,也非常喜歡,包括博主也會在上面上傳自己的開源代碼。最近,博主總是遇到無法訪問的情況,很是煩惱,通常博主總是雲淡風輕的點開我神器L-a-n-t-e-r-n搞定它,但是總是這樣也不是辦法,而且小夥伴們有不一定像博主一樣擁有神器。所以博主花了點時間在網上收集資料,找到一種親測可行的辦法,與君共享!
首先,貼上博主的開源項目地址,供大家點擊測試:SemiGlobalMatching
完美解決Github無法訪問及不顯示圖片問題
1. Github無法訪問的解決方式
問題描述: 站點無法訪問,有圖爲證:
解決辦法: 修改本機(windows操作系統)hosts文件
步驟:
-
打開hosts目錄:C:\Windows\System32\drivers\etc
-
複製hosts文件到桌面,打開,在最下面添加下列信息:
#github
140.82.113.4 github.com
199.232.69.194 github.global.ssl.fastly.net -
使用修改後的hosts文件覆蓋原文件
注意: 域名github.com和github.global.ssl.fastly.net對應的 ip 會因機器不同而不相同(就是第2步的兩個ip),使用該站點查詢對應域名的ip:https://www.ipaddress.com/ip-lookup。並用查詢的結果替換。
ip查詢方式:
- 打開網址:https://www.ipaddress.com/ip-lookup
- 在編輯框內鍵入域名,並點擊查詢按鈕查詢IP地址。
- 查詢後的兩個ip地址替換掉之前的ip地址。
- 修改完,驗證成果:
2. Github無法顯示圖片的解決方式
還有一種常見的情況是,Github無法顯示圖片,有圖爲證:
解決方案:
-
修改hosts
C:\Windows\System32\drivers\etc\hosts
-
在文件末尾添加:
#GitHub Start
192.30.253.112 github.com
192.30.253.119 gist.github.com
151.101.184.133 assets-cdn.github.com
151.101.184.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 -
修改後完,驗證結果:
搞定!