zl程序教程

您现在的位置是:首页 >  工具

当前栏目

GitHub添加远程库git push -u origin master时的问题fatal: Could not read from remote repository.

GitHubGit 远程 not 添加 from could Read
2023-09-11 14:20:02 时间

添加远程库时遇到问题

被拒绝

$ git push -u origin master

The authenticity of host '[ssh.github.com]:443 ([************]:443)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[ssh.github.com]:443,[**************]:443' (RSA) to the list of known hosts.
git@ssh.github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

解决方法:

首先,参考了这篇博客git上传代码报错ssh: connect to host github.com port 22: Connection timed out解决办法
,在ssh目录下创建了config文件。
在这里插入图片描述

但发现,还是不行,也许是因为别的问题?

又参考了第二篇博客,git push -u origin master 出现The authenticity of host 'github.com ’ can’t be established解决方案
,删除了原ssh文件下的id_rsa.pub后再重新创建远程连接。
参考如下:远程仓库| 廖雪峰

再次试验

$ git push -u origin master

Enumerating objects: 20, done.
Counting objects: 100% (20/20), done.
Delta compression using up to 4 threads
Compressing objects: 100% (15/15), done.
Writing objects: 100% (20/20), 1.64 KiB | 104.00 KiB/s, done.
Total 20 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), done.
To github.com:Mr007Z/learngit.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

Success!