【GitHub/Gitee】解决廖雪峰老师git教程ERROR: Repository not found。fatal: Could not read from remote repository.

【GitHub/Gitee】解决廖雪峰老师git教程ERROR: Repository not found。fatal: Could not read from remote repository._第1张图片
按照廖雪峰老师的教程到添加库那一步,执行git push 的时候

出现如下错误

ERROR: Repository not found.

fatal: Could not read from remote repository.

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

使用 cd ~/.ssh 查看了一下SSH key发现也没有问题,查阅了网上的一些解决方案,都是建议重置一个SSH key, 最后发现了问题所在,解决方法:
看本地的.git/config设置的仓库url地址和github使用的链接地址是否一致如下图,如use https,则url需要用https的仓库地址
***重点
将 git remote add github [email protected]:michaelliao/learngit.git
改成 git remote add github https://github.com/xxx/xxx.git

如上方法不适用,可以按照下面博客参考:

https://youcanping.cn/2017/12/20/ssh-Permission-denied/

解决方式
1 先看本地是否有ssh文件

cd ~/.ssh
ls
id_rsa id_rsa.pub known_hosts

2 有则把公钥加到github

cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVRgHi3gPdBcQ… [email protected]

3 github 添加公钥示意图
4 如果以上操作问题还不能解决,并且执行 ssh -T [email protected] 出现如下提示,说明本地公钥没有问题,则看第5步

ssh -T [email protected]
Hi youcanping! You’ve successfully authenticated, but GitHub does not provide shell access.

5 看本地的.git/config设置的仓库url地址和github使用的链接地址是否一致如下图,如use https,则url需要用https的仓库地址,我的就是这个问题。

cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote “origin”]
url = https://github.com/youcanping/MyBlog.git
fetch = +refs/heads/:refs/remotes/origin/
[branch “master”]
remote = origin
merge = refs/heads/master

6把公钥放到系统里[最佳答案]

ssh-add ~/.ssh/id_rsa
Identity added: /Users/youcanping/.ssh/id_rsa (/Users/youcanping/.ssh/id_rsa)

你可能感兴趣的:(【GitHub/Gitee】解决廖雪峰老师git教程ERROR: Repository not found。fatal: Could not read from remote repository.)