今天 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認證失敗了,或者一些其他未知的原因。