please make sure you have the correct access rights and the repository exists碼雲

ssh key有問題,連接不上服務器
在這裏插入圖片描述
git clone的時候遇到的這個問題,原來是我本地沒有設置好ssh
1、首先我得重新在git設置一下身份的名字和郵箱

git config --global user.name “yourname”

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

注:yourname是你要設置的名字,your@email是你要設置的郵箱。
2、刪除.ssh文件夾(.ssh在home 目錄下,ls -a )下的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、將全部的內容複製,粘貼到下面公鑰部分
在這裏插入圖片描述
5、在git中輸入命令:

ssh -T [email protected]

在這裏插入圖片描述
然後我在git pull的時候,又遇到了問題,提示說,因爲沒有相關的歷史所以不能合併refusing to merge unrelated histories
輸入以下命令:
git pull origin master --allow-unrelated-histories

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章