今天 git push 的時候報如下錯誤:
ssh: Could not resolve hostname gitcafe.com: nodename nor servname provided, or not known fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
最開始還以為是權限被修改了,后來問了朋友下,他建議使用 https 協議試試,看是否成功,如何在使用 ssh 協議的同時又使用 https 協議呢?我們只需要新增一個 remote 即可,步驟如下:
1、添加遠程倉庫
git remote add remoteName url
remoteName 倉庫名稱,可以自定義,不可和已有的倉庫名稱同名。這個名稱,push和pull的時候是需要用到的。默認的是 origin
2、獲取或推送
// pull git pull remoteName branchName // push git push remoteName branchName
結果發現push成功了,因此可以排除權限問題了。
那么出現這個原因的問題是什么?可能是服務器不穩定導致 ssh協議被gateway認證失敗了,或者一些其他未知的原因。