有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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.
有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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.
当前回答
这招对我很管用:
1-删除所有起源
git remote rm origin
(参见https://www.kernel.org/pub/software/scm/git/docs/git-remote.html)
*remote: "管理你所跟踪的分支的存储库集合("remotes")。
*rm: "删除已命名的远程。所有远程跟踪分支和远程配置设置都被删除。”
2-检查所有已删除:
git remote -v
3-添加新的产地主
git remote add origin git@github.com:YOUR-GIT/YOUR-REPO.git
这就是所有的朋友们!
其他回答
在将GitHub添加为远程时,使用该页面的URL。 它不会引起任何这样的错误和推动代码
如果您将ssh访问更改为https访问远程存储库,问题就解决了:
git remote set-url origin https_link_to_repository
git push -u origin master
如果您正在使用windows -10,请遵循此说明。这对我很管用。
以管理员身份打开终端 执行命令:"ssh-keygen"。它生成一个ssh密钥,并显示创建密钥的文件夹。检查我的图像 复制生成的ssh密钥 点击“新建SSH键按钮”并粘贴“SSH键”,最后“点击添加按钮”
如果您没有访问自己的存储库,或者在克隆的存储库中进行克隆(使用一些“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现在都可以在存储库页面的顶部找到。
我知道这个问题。添加ssh密钥后,也添加您的ssh密钥到ssh代理(来自官方文档)
ssh-agent -s
ssh-add ~/.ssh/id_rsa
一切正常工作后,git可以查看适当的密钥,以前不能。