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

什么好主意吗?


当前回答

如果您包括您的用户名和回购名称,我们可以合理地帮助您,目前我们没有理由认为回购确实存在。

此外,如果回购是私有的,并且您无法访问它,github将返回“不存在”,以避免披露私有回购的存在。

编辑:如果你不能克隆它,因为它说它不存在,它是私有的,这是因为你没有发送身份验证。确保您的公钥已添加到密匙环,或暂时使用HTTP基本身份验证。

其他回答

我得到了同样的错误,因为我改变了我的github用户名,然后我这样做:

git remote -v

然后:

git remote set-url newname newurl 
git push -u origin master

这次我能够推送到存储库。 我希望这能有所帮助。

我的解决办法是:

git remote rm origin
git remote add origin https://USERNAME@github.com/username/reponame.git

类似于Emi-C的答案,但没有密码。

一个问题,这可能是显而易见的一些,我没有看到这里提到,可能是你有ssh密钥访问,但你正试图通过https连接你的本地回购到远程。

如果是这种情况,那么下面的命令应该可以解决这个问题:

$ git remote -v
origin  https://github.com/private-repo.git (fetch)
origin  https://github.com/private-repo.git (push)
$ git remote rm origin
$ git remote add origin git@github.com:private-repo.git
$ git remote -v
origin  git@github.com:private-repo.git (fetch)
origin  git@github.com:private-repo.git (push)

请注意,上述工作的前提是: 您当前的远程名为origin,并且您已经拥有 生成SSH密钥连接到您的github帐户 你已经有一个SSH密钥与你的github帐户相关联(并在本地连接) 你有正确的权限(读/写)设置在github为这个回购的设置。

我的一个Github库也有同样的问题。

方法:

使用SSH而不是HTTPS,然后推/拉开始工作正常。

我得到了同样的错误

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

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