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

什么好主意吗?


当前回答

eval "$(ssh-agent -s)"

这是我自己的回购——应该有足够的使用权。对于其他回购,我能够拉和推没有问题。通过重新启动ssh-agent解决了这个问题。我用macos。

其他回答

如果你在Windows上使用Git,试着清除你的凭证:

找到“凭据管理器”(应该在控制面板中) 删除所有与GitHub相关的凭证

一个问题,这可能是显而易见的一些,我没有看到这里提到,可能是你有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为这个回购的设置。

这是如何解决我的问题

#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

SSH访问检查方法如下:

ssh -T git@github.com

这个问题是因为我没有在存储库中添加SSH上的人响应,阅读更多关于SSH link-1, link-2的信息。

所以对我来说,我的密码有一个'(勾),PhpStorm在发送git推送之前删除了这个字符:

在这个例子中,我的密码是_pa ' ' ssword_

Phpstorm将输出以下内容:

https://_username_:_password_@github.com/_username_/repo.git

而不是

https://_username_ _pa“ssword_@github.com/_username_/repo.git

将密码更改为不使用'字符的密码。工作! !