我在使用 git
和 github
时遇到了一个非常奇怪的问题。当我尝试进行推送时,我会得到以下错误消息:
git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
我添加了远程仓库:
git remote add origin git@github.com:account-name/repo-name.git
有任何想法吗?
解决方案: 2个选项remote: Repository not found. fatal: repository ‘https://github.com/MyOrganization/projectName.git/’ not found
user:password
克隆项目,以防您忘记了这个。或生成ssh令牌,并将此密钥调整到您的Github中。即 git push https://<userName>:<password>@github.com/Company/repositoryName.git
#check current github account
ssh -T git@github.com
#ensure the correct ssh key used with github
ssh-agent -s
ssh-add ~/.ssh/YOUR-GITHUB-KEY
#re-add the origin
git remote add origin git@github.com:YOUR-USER/YOUR-REPO.GIT
git push -u origin master
我通过重新使用 Github 进行身份验证来解决了这个问题。
如果您有 Github CLI,您可以输入 gh auth login
gh auth login --scopes write:org
命令,gh cli 可以轻松获得写入访问权限。 - Joakimhttps
从github克隆,但是使用ssh
推送,则也可能会遇到此错误。.git/config
文件并将以下内容替换为:
url = git@github.com:company/project.git
这样就可以无警告地推送了...我曾经遇到过同样的问题。多年来一切都正常,然后突然出现了这个错误。
问题的原因是我先将另一个仓库的部署密钥添加到SSH代理中,而不是先添加我的用户的GitHub SSH密钥(我总是用它来访问相关的仓库)。SSH代理首先尝试使用另一个仓库的部署密钥,而GitHub却出现了完全无法解释的问题。
ERROR: Repository not found.
当我从SSH代理中删除部署密钥后,一切都恢复正常了。
ssh-add -D
。这是在 macOS 上。 - dipeagit remote rm origin
git remote add origin git@github.com:account-name/repo-name.git
ssh -T git@github.com
Hi <github_account_name>! You've successfully authenticated, but GitHub does not provide shell access. I just had to give the access to fix the problem.
然后我明白了,在回答中描述的Github用户(github_account_name)没有被授权访问我尝试拉取的Github仓库。
The authenticity of host 'github.com (192.30.253.112)' can't be established. RSA key fingerprint is SHA256.... Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts. Permission denied (publickey).
- Nike Kov只需使用SSH远程URL而不是HTTPS
我在Github仓库中遇到了同样的问题。
使用
SSH
代替HTTPS
,然后push/pull
就可以正常工作了。
git remote add origin git@github.com:account-name/repo-name.git
的方式。它存在于GitHub上,是一个私有仓库。 - Justin[remote "origin"]
部分的URL键中。 - Ahmed Jehanzaib