有人看到这个错误并知道该怎么做吗?

我正在使用终端,我在根,GitHub存储库存在,我不知道现在该做什么。

> git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

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

当前回答

如果您没有访问自己的存储库,或者在克隆的存储库中进行克隆(使用一些“git submodule…”“命令):

在存储库的主目录中:

$ ls -a

1. 开放”。,你会发现这样的东西:

[submodule "XXX"]
    path = XXX
    url = git@github.com:YYY/XXX.git

将最后一行更改为您需要提取的存储库的HTTPS:

[submodule "XXX"]
    path = XXX
    https://github.com/YYY/XXX.git

保存”。“Gitmodules”,并为子模块运行命令。Git”将被更新。

2. 开放”。Git”,转到“config”文件,你会发现这样的东西:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://github.com/YYY/XXX.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[submodule "XXX"]
    url = git@github.com:YYY/XXX.git

将最后一行更改为您需要提取的存储库的HTTPS:

    url = https://github.com/YYY/XXX.git

因此,在本例中,主要问题只是url。任何存储库的HTTPS现在都可以在存储库页面的顶部找到。

其他回答

这发生在我身上。出于某种原因,我的出身在我没有意识到的情况下被搞砸了:

检查您的设置是否仍然正确

git remote -v

url需要像ssh://git@github.com/YourDirectory/YourProject.git; 如果没有看到git@github.com,请使用

git remote set-url origin git://github.com/YourDirectory/YourProject.git

纠正错误。或者你可以使用github应用程序在特定存储库的设置面板中检查和设置主远程存储库url。

排除故障的步骤

这发生在SourceTree上 在我的例子中,我的公私钥对出了问题。所以我删除这对并生成一个新的来解决我的问题

如果您将ssh访问更改为https访问远程存储库,问题就解决了:

git remote set-url origin https_link_to_repository

git push -u origin master

我也有同样的问题,但没有一个答案有效,但一个简单的解决方案有效。但是请注意,我确实首先添加了答案所建议的ssh密钥。不知道这是否真的有用。总之,这是最后成功的方法:

使用git远程将远程的URL从HTTPS更改为SSH set-url命令。$ git remote set-url origin git@github.com:USERNAME/REPOSITORY.git。验证远程URL 已经改变了。

您可以使用Https url登录

我猜你是试图登录SSH url 当你说git push,如果它只要求密码,考虑你是通过ssh连接。最好使用HTTP url。