git之fatal: Could not read from remote repository


問題背景:
在git bash中使用hexo g -d命令進行文章發布

詳細錯誤信息:


fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: Connection reset by 13.250.177.223 port 22
fatal: Could not read from remote repository.

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

    at ChildProcess.<anonymous> (E:\Hexo\node_modules\hexo-util\lib\spawn.js:37:17)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at ChildProcess.cp.emit (E:\Hexo\node_modules\cross-spawn\lib\enoent.js:40:29)
    at maybeClose (internal/child_process.js:915:16)
    at Socket.stream.socket.on (internal/child_process.js:336:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:561:12)

錯誤原因是因為ssh key有問題,連接不上服務器。

於是我參考如下鏈接,一步一步操作,最終解決了這個問題:
git遇到的問題之“Please make sure you have the correct access rights and the repository exists.”

雖然已經有了問題的解決答案,但是我覺得還是需要列舉一下相關步驟,梳理一下:

1.重新在git設置一下身份的名字和郵箱

git config --global user.name "yourname"

git config --global user.email "your@email.com"

這里的yourname必須與github的用戶名一致

這里your@email.com必須與github登錄郵箱一致

 

2.刪除.ssh文件夾下的known_hosts文件(該文件主要作用是域名解析)

 

3.ssh-keygen -t rsa -C “your@email.com(填寫github對應的郵箱)”

一路回車即可,無需輸入

 

4.進入github設置界面

 

新增SSH key將id_rsa.pub內容添加到如圖中的Key上(title可任意命名):

5.最后完美解決這個問題


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM