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

什么好主意吗?


当前回答

我也遇到了同样的问题,我通过在回购url中包含我的用户名和密码来解决它:

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

其他回答

我试了所有的办法,但似乎都不管用。进一步的研究表明:

这里有一个解决问题的综合方法。 当你数到5。修复4,注意VS代码会要求认证。

如果您输入了密码,仍然得到身份验证错误,请执行以下操作。

转到你的GitHub菜单做设置->开发人员设置->个人访问令牌->生成新的令牌。并确保这些框都是按照下图选中的。生成一个访问令牌并将其保存在可访问的地方。 使用生成的令牌而不是密码。 然后继续执行步骤6。修复5

这些步骤可以在事后解决问题。

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

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

它类似于接下来的两行:

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

当我试图推到我以前访问过的私人回购时,我遇到了这个错误。问题不在于回购是私有的还是公共的,问题在于Github API现在使用个人令牌而不是用户名和密码进行身份验证和授权。

以下方法解决了我的问题:

删除远程原点:git远程删除原点 生成一个个人代币:你可以在Github Docs中找到说明。 重新添加原点,但使用您的用户名和生成的令牌:

git远程添加origin https://USERNAME:GENERATED_TOKEN@github.com/username/reponame.git

注意: 如果在创建和使用令牌一段时间后遇到此问题,请确保令牌没有过期。如果是,重新生成它,并确保对使用旧令牌的回购重复第3步(如上所述)。此外,如果您更改了令牌,请为使用旧令牌的repo重做步骤3。

Normally it happens because the project is private and you have not rights to write it. I had the same "problem" a few times, and it was for that reason. If the project it is yours, just create a private and a public key following this link: https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent and add them to the "SSH and Key" section on gitHub, then you will be able to push to the repo. In the other hand if the project it is not your, ask the owner to give you the rights for it.

我也有同样的问题。

我解决了把我的gitlab用户名前缀到gitlab.com url的问题,就像这样: 之前: https://gitlab.com/my_gitlab_user/myrepo.git 后: https://my_gitlab_user@gitlab.com/my_gitlab_user/myrepo.git 在这种情况下,将再次要求凭据,这就完成了!