最近用git提交代码时候,踩了很多坑。也参阅了很多的答案,发现写的都不是很完整,为了防止忘记,在此记录一下。

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

谷歌后,发现是ssh key有问题,导致的连接不上服务器。

1、首先要重新在git设置一下身份的名字和邮箱。

git config --global user.name "yourname"

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

注:yourname是你要设置的名字,[email protected]是你要设置的邮箱。

 

2、删除.ssh文件夹(直接搜索该文件夹,一般在C盘的Users文件夹下)下的known_hosts(手动删除即可,不需要git)

注:有些小伙伴的电脑里面可能找不到这个文件夹和known_hosts文件,不过不要紧。可以直接跳过这步执行下一步。

 

3、git输入命令

ssh-****** -t rsa -C "[email protected]"(标红部分请填你设置的邮箱地址,别直接复制)

接着出现如下图:

出现下图后,直接按回车。然后去红框内的路径,找.ssh文件夹。 以下仅为例子每个人路径可能不同,照着这部分显示的路径去找就能找到。系统会自动在.ssh文件夹下生成两个文件,id_rsa和id_rsa.pub,用记事本打开id_rsa.pub。将全部的内容复制。

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.”

 

4、打开https://github.com/,登陆你的账户,进入设置

进入ssh设置,步骤如下图所示:

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.”

git提示“Please make sure you have the correct access rights and the repository exists.”

 

 

在key中将刚刚复制的id_rsa.pub中的内容粘贴进去。

git提示“Please make sure you have the correct access rights and the repository exists.”

 

点击add ssh key。就完事了。

 

5、在git中输入命令:

ssh -T [email protected] 

然后耐心等待,过一会出现一大堆英文。后面括号内会让你输入命令(yes/no)。

输入命令:yes

按回车。

然后就会提示你成功了。

最后退出git重新进入路径提交或者git clone一下就可以了。

相关文章: