【问题标题】:Git push: "ERROR: Repository not found' - "fatal: Could not read from remote repository"Git push:“错误:找不到存储库”-“致命:无法从远程存储库读取”
【发布时间】:2019-10-24 10:13:11
【问题描述】:

总之

目标:使用 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")

【问题讨论】:

    标签: github ssh-keys git-push droplet


    【解决方案1】:

    首先,确保远程存储库确实存在并且首先在 GitHub 上创建。
    看看能不能浏览https://github.com/[username]/[repository]的页面

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-13
      • 1970-01-01
      • 2022-10-23
      • 2012-11-10
      • 2015-01-17
      • 2014-05-04
      • 2015-01-19
      相关资源
      最近更新 更多