1. 程式人生 > >(轉)git遇到的問題之“Please make sure you have the correct access rights and the repository exists.”

(轉)git遇到的問題之“Please make sure you have the correct access rights and the repository exists.”

key pair 遇到 重新 出了 csdn ssh-key vat work 直接

對於git的提交一直很小心翼翼,感覺一不小心就會踩到莫名的坑。

這不,

某天commit 就遇到了On branch master nothing to commit (working directory clean)

一查意思。你的分支很幹凈?

幹凈?excuse me?

然後git push origin master一下,漫長等待了彈出了fail:#¥%@(此處省略,我們看重點)

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

然後谷歌了一下,原來是ssh key有問題,連接不上服務器~~

然後我開始了死胡同~~

技術分享圖片

參閱了很多的答案,發現寫的都不是很完整,自己東摸索西摸索搞定了,怕忘記,記錄一下

1、首先我得重新在git設置一下身份的名字和郵箱(因為當初都忘了設置啥了,因為遇到坑了)進入到需要提交的文件夾底下(因為直接打開git Bash,在沒有路徑的情況下,根本沒!法!改!剛使用git時遇到的坑。。。)

git config --global user.name "yourname"

git config --global user.email“[email protected]"

註:yourname是你要設置的名字,your@email是你要設置的郵箱。

2、刪除.ssh文件夾(直接搜索該文件夾)下的known_hosts(手動刪除即可,不需要git)

3、git輸入命令

$ ssh-keygen -t rsa -C "[email protected]"(請填你設置的郵箱地址)

接著出現:

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):

請直接按下回車

然後系統會自動在.ssh文件夾下生成兩個文件,id_rsa和id_rsa.pub,用記事本打開id_rsa.pub

將全部的內容復制

4、打開https://github.com/,登陸你的賬戶,進入設置

進入ssh設置

技術分享圖片

技術分享圖片

在key中將剛剛復制的粘貼進去

技術分享圖片

點擊add ssh key,

ok!

5、在git中輸入命令:

ssh -T [email protected]

然後會跳出一堆話。。

輸入命令:yes

回車

然後就會提示你成功了~~

淚牛滿面~~

(轉)git遇到的問題之“Please make sure you have the correct access rights and the repository exists.”