1. 程式人生 > >git提示錯誤關於錯誤:ssh: Could not resolve hostname github.com: Name or service not known.fatal: Could not read from remote repository.

git提示錯誤關於錯誤:ssh: Could not resolve hostname github.com: Name or service not known.fatal: Could not read from remote repository.

eight 無法讀取 主機名 github上 錯誤2 winsock nal file drive

關於 Git 使用中出現的錯誤

技術分享圖片 饑人谷_楠柒 2016.11.02 15:33* 字數 746 閱讀 3607評論 5

關於錯誤:ssh: Could not resolve hostname github.com: Name or service not known.fatal: Could not read from remote repository.

技術分享圖片 QQ截圖20161102144048.jpg
在我配置完公鑰後想要進行遠端Github上clone時出現了錯誤。經過網上查詢發現在配置git時要驗證是否成功。要在git bash 下輸出$ ssh -T [email protected]如果是第一次的會提示是否continue,輸入yes就會看到:You’ve successfully authenticated, but GitHub does not provide shell access 。這就表示已成功連上github。

但是 我輸入後並不是這樣的,我的顯示Host key verification failed.於是查詢中。。。。。
經查找後發現我在git bash 下打出ping github.com 不顯示ip。之前對git使用並不太了解。也在網上查找了相關錯誤的解決辦法但都沒有用。(如該DNS等等)最後還是找到了問題的所在。

如果有朋友出現了以下三條錯誤可以按我下面的操作試試。
錯誤1.


技術分享圖片 QQ截圖20161102144048.jpg

clone
ssh:無法解析主機名github.com:名稱或服務不知道
無法讀取遠程存儲庫。
請確保您有正確的訪問權限
和存儲庫存在。(錯誤代碼)

錯誤2.
在git bash 下輸出$ ssh -T [email protected]也顯示錯誤。(表示git連接github失敗)

錯誤3.
在git bash 下打出ping github.com 不顯示ip。

原因有可能是本地DNS無法解析導致的。造成該問題的因素可能有多種,安全防護類軟件、病毒、優化或清理等導致本地DNS解析文件被清除或更改,DNS緩存問題,Winsock目錄問題等。

解決辦法

  1. 先去復制一下別人的hosts 該文件在C:\Windows\System32\drivers\etc路徑下
    把復制的文件放入該路徑下 原來的不要


    技術分享圖片 QQ截圖20161102151526.jpg
  2. 進入cmd (開始->搜索文件和程序->打入cmd->enter)
    輸入:ipconfig /flushdns 釋放DNS緩存。
    輸入:netsh winsock reset 重置Winsock目錄。
    會有提示:必須重啟計算機才能完成重置。
    先不要著急重啟。

  3. 在cmd裏隨意ping一個網址試試(如圖)

技術分享圖片 QQ截圖20161102152243.jpg

無丟失表示成功了。再重啟你的計算機。

  1. 重啟後進入你的git bash 試試 ping github.com
    應該會顯示你的ip地址。在git bash下輸出$ ssh -T [email protected]如果是第一次的會提示是否continue,輸入yes就會看到:You’ve successfully authenticated, but GitHub does not provide shell access 。這就表示已成功連上github。

  2. 之後你的git clone就不會出現錯誤提示(
    ssh: Could not resolve hostname github.com: Name or service not known
    fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

這只是我個人在使用git時碰到的問題,希望能夠幫助其他朋友。如果有朋友再使用git時還碰到其他解決不了的問題希望我可以幫到你(請留言)。建議碰到問題先在網上自己查詢,雖然很浪費時間但問題的所在和解決的辦法或讓你難以忘懷!!

git提示錯誤關於錯誤:ssh: Could not resolve hostname github.com: Name or service not known.fatal: Could not read from remote repository.