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

什么好主意吗?


当前回答

这解决了我的问题。

   git pull https://myusername:mypassword@github.com/path_to/myRepo.git

其他回答

在我的情况下,这是因为我在另一个GitHub帐户也添加了相同的SSH密钥。检查和修复步骤

检查它:ssh -T git@github.com。如果显示了正确的用户名,那么问题就不同了。如果是另一个帐户,则执行步骤2。 简单地去另一个帐户,并删除ssh密钥从那里。 不同的帐户使用不同的密钥。Github把它们搞混了。

在执行此操作之前,请确保您拥有对回购的写权限。如果您仍然得到错误,请执行以下操作:

Generate a personal access token from your account from Settings > Developer Settings > Personal Access tokens. Keep the token safe somewhere. Go to your repository and run the following: git remote rm origin Then add a new origin along with your username: git remote add origin https://USERNAME@github.com/REPOSITORY_LINK.git Now when you push the code, a prompt will show up asking for your password or personal access token. Paste the token that we generated in the first step in the field, and we're done.

如果您确定已经拥有对这个存储库的SSH访问权限。

Do

git clone https://myusername@github.com/path_to/myRepo.git

在我的情况下,这是由git使用错误的ssh私钥引起的。 我在学校使用的特定github用户帐户下获得了访问存储库的权限。我的默认ssh私钥不幸链接到不同的github帐户。

如果您使用ssh -T git@github.com ssh将自动使用您的id_rsa私钥连接到github。

使用ssh -i ~/。ssh/<some-key> -T git@github.com应该导致github欢迎您与您链接到该密钥的帐户。

所以在我的情况下发生的是,git正在使用我的默认ssh私钥,该私钥链接到错误的github帐户,该帐户没有访问我试图访问的私有存储库。

为了解决这个问题,我告诉git使用正确的ssh命令在本地git配置我的repo使用命令:git config core。ssh -i ~/.使用实例Ssh /<正确的私钥here>"

查看git配置git config -l应该显示行被正确添加。

如果你使用https从github克隆,但你使用ssh推送,你也会得到这个错误。

要纠正这个问题,打开.git/config并替换:

Url = https://github.com/company/project.git

With

Url = git@github.com:company/project.git

你应该可以在没有任何警告的情况下推…