我收到此错误 -
D:\Projects\wamp\www\REPO [master]> git pull origin master
Warning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of known hosts.
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
git remote -v的输出
D:\Projects\wamp\www\REPO [master]> git remote -v
origin git@github.com:username/repo.git (fetch)
origin git@github.com:username/repo.git (push)
Run Code Online (Sandbox Code Playgroud)
ssh -Tv git@github.com命令的最后消息-
Hi [My Username]! You've successfully authenticated, but GitHub does not provide shell access.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
小智 36
对我来说,我收到此错误是因为我的 ssh 代理未以某种方式运行。这样做有效:
eval `ssh-agent -s`
ssh-add path_to_your_key
Run Code Online (Sandbox Code Playgroud)
Siy*_*lav 35
通过您的远程"来源"的http网址更改您的ssh网址,请使用:
> git remote set-url origin https://github.com/<user_name>/<repo_name>.git
Run Code Online (Sandbox Code Playgroud)
它会在git push上询问你的GitHub密码.
Von*_*onC 15
我在讨论中问道:
确实
ssh -T git@github.com输出中相同的用户名(in Hi [My Username]!),如用于您的回购协议的SSH URL的一个(git@github.com:username/repo.git)?抱歉,它没有显示相同的名称
这意味着凭证已经改变了.
一个解决办法是至少副本%HOME%\.ssh\id_rsa.pub在右边的GitHub帐户的SSH密钥部分
OP增加:
我正在私人回购.所以在git@github.com:username/repo.git,
我回答:
如果您能够克隆/推送到其用户名不是您自己的GitHub帐户的repo,那一定是因为您已将先前的公共ssh密钥添加为repo所有者的该repo的贡献者.
接下来要问同一个repo所有者将当前的公共ssh密钥添加
%HOME%\.ssh\id_rsa.pub到repo贡献者列表中.
因此,请与所有者核实您(意味着您的公共ssh密钥)被声明为贡献者.
PHP*_*... 15
当您使用两个 ssh 密钥访问两个不同的 GitHub 帐户时,通常会发生这种情况。
按照以下步骤解决这个问题,它看起来太长了,但相信我不会超过 5 分钟:
步骤 1:创建两个 ssh 密钥对:
ssh-keygen -t rsa -C "your_email@youremail.com"
Run Code Online (Sandbox Code Playgroud)
第 2 步:它将在这里创建两个 ssh 密钥:
~/.ssh/id_rsa_account1
~/.ssh/id_rsa_account2
Run Code Online (Sandbox Code Playgroud)
第 3 步:现在我们需要添加这些键:
ssh-add ~/.ssh/id_rsa_account2
ssh-add ~/.ssh/id_rsa_account1
Run Code Online (Sandbox Code Playgroud)
- 您可以使用以下命令查看添加的密钥列表:
ssh-add -l- 您可以通过以下命令删除旧的缓存密钥:
ssh-add -D
步骤 4:修改 ssh 配置
cd ~/.ssh/
touch config
Run Code Online (Sandbox Code Playgroud)
subl -a config或code config或nano config
第 5 步:将此添加到配置文件:
#Github account1
Host github.com-account1
HostName github.com
User account1
IdentityFile ~/.ssh/id_rsa_account1
#Github account2
Host github.com-account2
HostName github.com
User account2
IdentityFile ~/.ssh/id_rsa_account2
Run Code Online (Sandbox Code Playgroud)
第 6 步:更新您的.git/config文件:
步骤 6.1:导航到 account1 的项目并更新主机:
[remote "origin"]
url = git@github.com-account1:account1/gfs.git
Run Code Online (Sandbox Code Playgroud)
如果您在他们的 git 存储库中受到其他用户的邀请。然后你需要像这样更新主机:
[remote "origin"]
url = git@github.com-account1:invitedByUserName/gfs.git
Run Code Online (Sandbox Code Playgroud)
步骤 6.2:导航到 account2 的项目并更新主机:
[remote "origin"]
url = git@github.com-account2:account2/gfs.git
Run Code Online (Sandbox Code Playgroud)
第 7 步:如果需要,单独更新每个存储库的用户名和电子邮件,这不是修改步骤:
导航到 account1 项目并运行这些:
git config user.name "account1"
git config user.email "account1@domain.com"
Run Code Online (Sandbox Code Playgroud)
导航到 account2 项目并运行这些:
git config user.name "account2"
git config user.email "acccount2@doamin.com"
Run Code Online (Sandbox Code Playgroud)
ssh-add -D # Delete all identities.
ssh-add ~/.ssh/your_key
Run Code Online (Sandbox Code Playgroud)
编辑 1
由于我得到了这么多选票,我发现了这种方法的一些问题,那就是它会删除您的所有身份,因此当您尝试从其他存储库读取数据时,您可能会遇到相同的问题,并且您需要再次执行此步骤对于每个项目......但也可能不是您的项目的情况
这个错误也发生在我身上,因为原始存储库创建者离开了公司,这意味着他们的帐户从 github 团队中删除。
git remote set-url origin https://github.com/<user_name>/<repo_name>.git
然后
git pull origin develop或者你想执行的任何 git 命令都应该提示你登录并继续正常运行。
有时,仅将pub ssh密钥复制到github / bitbucket还是不够的,尤其是对于Bitbucket。您可能还需要检查ssh是否使用了您期望的身份,而不是搞乱了git remote
检查代理程序是否使用与您粘贴在github / bitbucket上的相同身份ssh-add -l。如果缺少添加
ssh-add ~/.ssh/id_rsa_my_git_identity
更多详细信息:https : //confluence.atlassian.com/bitbucket/configure-multiple-ssh-identities-for-gitbash-mac-osx-linux-271943168.html
此错误可能是因为本地计算机上没有 SSH 密钥。在本地检查 SSH 密钥:
$ cat ~/.ssh/id_rsa.pub
Run Code Online (Sandbox Code Playgroud)
如果上面的命令没有给出任何输出,请使用下面的命令来创建 ssh 密钥(Linux/Mac):
$ ssh-keygen
Run Code Online (Sandbox Code Playgroud)
现在再次运行cat ~/.ssh/id_rsa.pub这是您的 SSH 密钥。将此密钥复制并添加到 git 中的 SSH 密钥中。在 gitlab/bitbucket 中转到
profile settings -> SSH Keys -> add Key
Run Code Online (Sandbox Code Playgroud)
并添加密钥