我有一个非常奇怪的问题与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使用错误的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应该显示行被正确添加。

其他回答

你必须生成SSH密钥,并在设置中添加到你的github帐户中 转到你的项目,在那里你克隆里面运行这些命令

1-ssh keygen -t rsa -b 4096 -C "rajankumar148@gmail.com"

在命令之后,你会得到一些选项,路径和名称可以留空,你可以输入密码。

2-eval $(ssh-agent -s)。

3-ssh-add ~ / . ssh / id_rsa

在这个命令之后,您必须输入与第一个命令中创建的相同的密码

之后,你可以检查你的默认主目录或任何目录,它在终端上显示。pub文件打开并复制密钥和过去在github设置新的SSH

这也可能发生,因为GitHub本身宕机了。一定要检查stat.github.com,看看问题是否在他们那边。

2018年10月22日,你有好几个小时都无法推送到GitHub。

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

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

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

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

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

自2021年5月以来,我(和许多其他人)就遇到了这个问题。 有些东西似乎已经改变了行动/checkout@v2 (GitHub问题:https://github.com/actions/checkout/issues/254)

我通过使用此步骤更改运行程序对回购进行身份验证的方式来解决这个问题。

- name: Bump version
    env:
      NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
    run: |
      npm run release
      git remote rm origin
      git remote add origin https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/project/repo.git
      git remote -v # for debug only 
      git show-ref # for debug only 
      git push --follow-tags origin HEAD:master

所有你需要做的是改变回购url。用户名和密码将在运行时由GitHub运行器替换。这适用于actions/checkout@v1和actions/checkout@v2(还没有测试其他)。

此外,你在网上找到的许多代码片段已经带有权限限制,这将阻止你推回回购

permissions:
   packages: write
   contents: read

确保你删除了这个或授予你的动作内容:如果你需要推送一个标签或提交发行说明和包碰撞,写许可。

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.