git push 出错: “Please make sure you have the correct access rights and the repository exists.“

时间:2024-03-14 08:30:09

对于git的操作,笔者是图形化界面工具和git命令混合使用的,一直都没有出过什么问题,直到有天用着熟悉的操作 git push,结果一直不成功 报错信息永远就是这一个

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

一顿谷歌之后终于解决了,原来是ssh key有问题,连接不上服务器;整理了记录下步骤,防止以后出现同样的问题找解决方案费时间:

  1. 进入要提交的文件夹下面,进入gti Bash命令行界面,重置下用户名和邮箱:

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

    标注:yourname是你的git用户名,[email protected]是你的git库的邮箱,(笔者直接用的github上面的账户和邮箱)

  2. 删除.ssh文件夹下的known_hosts(直接搜索该文件夹,但是笔者搜索文件夹太慢了,搜很久都没有找到.ssh文件夹目录, 后面自己瞎点还真的找到了 _ Windows的小伙伴可以参考目录:C:\Users\cdzr-wy.ssh)(手动删除即可,不需要git)

  3. 继续在git Bash中输入命令

    $ ssh-****** -t rsa -C “[email protected](请填你第一步设置的邮箱地址)

    命令输下后,一路回车,回车 最终结果如下图所示之后,.ssh文件下面会自动生成两个文件id_rsaid_rsa.pub, 将id_rsa.pub用记事本打开,复制里面所有的内容

git push 出错: “Please make sure you have the correct access rights and the repository exists.“
4. 打开github,登陆你的账户,进入setting

git push 出错: “Please make sure you have the correct access rights and the repository exists.“
git push 出错: “Please make sure you have the correct access rights and the repository exists.“
git push 出错: “Please make sure you have the correct access rights and the repository exists.“
5. 然后继续在git Bash输入命令

$ ssh -T [email protected], 会跳出一段话,直接输入 yes 回车即可,然后就会提示成功

git push 出错: “Please make sure you have the correct access rights and the repository exists.“
6. 最后退出下 git Bash 重新进入 进行git push 就可以了