Git推送:“错误:找不到存储库”-“致命:无法从远程存储库读取”

时间:2019-06-09 23:38:49

标签: github ssh-keys git-push droplet

简而言之

目标:使用ssh而非https执行一次成功的git push。

问题::“错误:找不到存储库。致命:无法从远程存储库读取”。

分步背景

我正在使用Ubuntu远程服务器(DigitalOcean开发的Droplet)和Github帐户。我在Ubuntu远程服务器上创建了一个ssh公用密钥,并用它在Github上创建了一个新的ssh密钥。然后,我使用git remote set-url命令将远程URL从https更改为ssh:

git remote set-url origin git@github.com:[username]/[repository].git

接着,我测试了是否可行:

root@[DropletName]:/srv/test_git_folder# ssh -T git@github.com
The authenticity of host 'github.com (140.87.148.9)' can't be established.
RSA key fingerprint is SHA365:mVhbp6kXUbJWCl7E1IGOCspRamTxdCARLviWk6F5SY9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,140.87.148.9' (RSA) to the list of known hosts.
Hi [Username]! You've successfully authenticated, but GitHub does not provide shell access.

这时我试图创建一个短文本文件...

root@[DropletName]:/srv/test_git_folder# nano testfile2.txt
[nano text editor appears; I input "Hello world!", save and close]

...并将其推送到github

root@[DropletName]:/srv/test_git_folder# git add *
root@[DropletName]:/srv/test_git_folder# git commit -m "test push"
[master 5b6bcb0] test push
 1 file changed, 1 insertion(+)
 create mode 100644 testfile2.txt

但是最后我收到了一条错误消息:

root@[DropletName]:/srv/test_git_folder# git push –u origin master

ERROR: Repository not found.
fatal: Could not read from remote repository.

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

我该如何解决?

(我一直在寻找一些类似的问题,包括以下内容: -Git : Could not read from remote repository -CentOS: Git: "fatal: could not read from the remote repository" -git push to remote repository "Could not read from remote repository"

1 个答案:

答案 0 :(得分:0)

首先,确保远程存储库确实存在并且已首先在GitHub上创建。
查看您是否可以浏览https://github.com/[username]/[repository]

上的页面

然后在git remote -v中键入/srv/test_git_folder来检查URL是否正确(相同的大小写,因为它区分大小写)