问题描述:
在推送代码时,控制台报错
Please make sure you have the correct access rights and the repository exists
// 请确保您具有正确的访问权限并且存储库存在
原因:
公钥配置出问题了,删除旧公钥,重新配置新公钥即可。
解决步骤:
删除.ssh下所有文件
![](https://img-blog.csdnimg.cn/img_convert/722fb08deeccf5d980b7f450bced8eb1.png)
在桌面上点击鼠标右键,进入git bash hear
![](https://img-blog.csdnimg.cn/img_convert/9c7f79dd962d8120a1472b68584dac55.png)
配置本地用户名及邮箱
![](https://img-blog.csdnimg.cn/img_convert/27cae45f9b0ee8ce3fa5d7e2fa3a226b.png)
# 配置用户名
git config --global user.name "用户名"
# 配置邮箱
git config --global user.email "邮箱地址"
以上命令执行结束后,可用 git config list 命令查看配置是否成功
git生成公钥
在git bash窗口输入下面指令即可生成带注释的公钥
ssh-keygen -t rsa
输入代码后按回车3下(为什么按三下,是因为有提示你是否需要设置密码,如果设置了每次使用Git都会用到密码,一般都是直接不写为空,直接回车就好了)。会在.ssh文件夹里面生成一个私钥 id_rsa和一个公钥id_rsa.pub。
如需在代码窗查看可执行查看公钥的命令:
cat ~/.ssh/id_rsa.pub
![](https://img-blog.csdnimg.cn/img_convert/99930fc7c507c35629fdd1a3b76aae64.png)
打开代码管理平台,配置SSH密钥即可
![](https://img-blog.csdnimg.cn/img_convert/de6ccd1ea70babe969d708fb50c3ece9.png)
最后再重新去提交代码即可,问题迎刃而解 !