当前位置:Gxlcms > 数据库问题 > 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.问题解决

时间:2021-07-01 10:21:17 帮助过:59人阅读

问题描述:把本地库里的内容推送到远程库的时候出错?

git push -u origin master
fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists;

这个问题当时真是困扰了我很久,后来看了别人的博客豁然开朗了。

其实是公钥出了问题,要先设置用户名和邮箱再重新生成ssh公钥即可。

1.首先我得重新在git设置一下身份的名字和邮箱 进入到需要提交的文件夹底下(因为直接打开git Bash,在没有路径的情况下,根本没!法!改!刚使用git时遇到的坑。。。)

git config --global user.name "yourname"

git config --global user.email "your@email.com"

这里我觉得邮箱地址最好与你GitHub上的邮箱地址一致。

2.删除.ssh文件夹(直接搜索该文件夹)下的known_hosts(手动删除即可,不需要git)

ssh在C盘里面,直接搜索即可。(删除之后不要关闭,还会用到)

3.git输入命令

$ ssh-keygen -t rsa -C "your@email.com"(请填你设置的邮箱地址)

然后一直回车即可。
然后系统会自动在.ssh文件夹下生成两个文件,id_rsa和id_rsa.pub,用记事本打开id_rsa.pub将全部的内容复制

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

技术图片

技术图片
在key中将刚刚复制的粘贴进去
技术图片
点击add ssh key

重新输入git命令

  1. $ git remote rm origin 删除远程库
  2. git remote add origin git@github.com:michaelliao/learngit.git 重新关联远程库
  3. git push -u origin master 再次把库里面的内容推到远程库里面。
    ok!问题解决了!!!

csdn地址:https://www.liaoxuefeng.com/wiki/896043488029600/898732864121440

git:Please make sure you have the correct access rights and the repository exists.问题解决

标签:问题   master   用户名   git   自动   conf   ssh公钥   问题解决   推送   

人气教程排行