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

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

其他回答

这是如何解决我的问题

#check current github account
ssh -T git@github.com

#ensure the correct ssh key used with github
ssh-agent -s
ssh-add ~/.ssh/YOUR-GITHUB-KEY

#re-add the origin
git remote add origin git@github.com:YOUR-USER/YOUR-REPO.GIT
git push -u origin master

如上Alex所说,更改.git/config文件的内容会有所帮助。我也遇到了同样的问题,我想这是因为我更改了我的Github用户名。无法使用更改更新本地文件。所以当你改变你的用户名时,你可能会考虑跑步

Git远程添加原点your_ssh_link_from_github

我希望这对你有所帮助;)

这解决了我的问题。

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

我也有同样的问题。试试下面的方法: 1. 修改密钥链访问在Mac的git凭证解决了我的问题。 2. 重置原始url

git remote rm origin
git remote add origin git@github.com:account-name/repo-name.git

我需要杀死凭证帮助进程(有多个),它在再次提供凭证后解决了这个问题。

killall git-credential-cache——守护进程