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

什么好主意吗?


当前回答

自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

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

其他回答

我的问题是我创建了一个没有权限的个人开发人员令牌

问题:由于某些原因,Github不熟悉你的存储库。

Error:在git cli中提示如下:

remote:未找到存储库。致命:库 “https://github.com/MyOrganization/projectName.git/”未找到

解决方案:2个选项

Github might not familiar with your credentials: - The first Option is to clone the project with the right credentials user:password in case you forgot this Or generate ssh token and adjust this key in your Github. aka git push https://<userName>:<password>@github.com/Company/repositoryName.git Repo Permissions Issue with some users - In my Use case, I solved this issue when I realized I don't have the right collaborator permissions on Github in my private repo. Users could clone the project but not perform any actions on origin. In order to solve this:

去Github上的仓库->设置->合作者和团队->添加 成员/维护你的用户->现在他们获得了提交的权限 ,推动

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

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

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

With

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

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

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

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

它类似于接下来的两行:

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

我也有同样的问题。我的问题是误解,我必须先在github上创建空的回购,然后再推到它。哎!包括这个给那些没意识到的人。