我有一个非常奇怪的问题与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

什么好主意吗?


当前回答

我用的是Mac,我努力寻找解决方案。 我的远程地址是正确的,如前所述,这是一个证书问题。 显然,过去我在我的电脑上使用了另一个Git帐户,mac的钥匙链记住了前一个帐户的凭据,所以我真的没有被授权推送。

如何修复? 在mac上打开钥匙链访问,选择“所有项目”类别并搜索git。 删除所有找到的结果。

现在去终端再按一次。终端会要求输入用户名和密码。输入新的相关凭证,就是这样!

希望它能帮助到别人。我挣扎了几个小时。

其他回答

对我来说,这些回答都没用。 我只是忘记在远程(github.com)上创建回购。所以我在网上创建了我的回购,用同样的名字,然后重新做

所以,这是整个故事:

git init ...
git add ...
git commit ...
git remote add origin git@github.com:<myName>/<myRepo>.git
git push -u origin main

ERROR: Repository not found.
fatal: Could not read from remote repository.

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

这里你需要在github.com上添加你的回购,使用相同的“myRepo”名称

git push -u origin main 

我得到了同样的错误

ERROR: Repository not found.   
fatal: The remote end hung up unexpectedly

我在Github上创建了存储库,并在本地克隆了它。

我可以通过打开.git/config并删除[remote "origin"]部分来解决。

[remote "origin"]   
   url = git@github.com:alexagui/my_project.git  
   fetch = +refs/heads/*:refs/remotes/origin/*

然后我运行以下程序(再次)

git remote add origin git@github.com:alexagui/my_project.git  
git push -u origin master

这一次我可以推到存储库。

有类似的问题。问题的根源是我遵循了一些关于向Github添加新存储库的在线教程。

只要去Github,创建一个新的repo,它会要求你添加一个README,不要添加它。创建它,你会得到如何推送的指导。

它类似于接下来的两行:

git remote add origin https://github.com/YOUR_USER/your-repo.git
git push -u origin master

我的解决方案可能对你们中的一些人有用。

我把笔记本电脑的操作系统更新到优胜美地后,也出现了同样的错误。通过重新创建ssh密钥,我的问题得到了解决。您可以通过执行本页的第2步完成此操作:https://help.github.com/articles/generating-ssh-keys/

如上Alex所说,更改.git/config文件的内容会有所帮助。我也遇到了同样的问题,我想这是因为我更改了我的Github用户名。无法使用更改更新本地文件。所以当你改变你的用户名时,你可能会考虑跑步

Git远程添加原点your_ssh_link_from_github

我希望这对你有所帮助;)