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

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