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

什么好主意吗?


当前回答

我用的是Mac,我努力寻找解决方案。 我的远程地址是正确的,如前所述,这是一个证书问题。 显然,过去我在我的电脑上使用了另一个Git帐户,mac的钥匙链记住了前一个帐户的凭据,所以我真的没有被授权推送。

如何修复? 在mac上打开钥匙链访问,选择“所有项目”类别并搜索git。 删除所有找到的结果。

现在去终端再按一次。终端会要求输入用户名和密码。输入新的相关凭证,就是这样!

希望它能帮助到别人。我挣扎了几个小时。

其他回答

如果使用私有存储库检查连接用户,则该用户必须具有使用存储库的权限。

这对我来说很管用:

1. 的遥控器

$ git remote rm origin
$ git remote add origin git@github.com:<USER>/<REPO>.git

如果您的SSH密钥已经在另一个github代表上使用,您可以生成一个新密钥。

2. 生成新的SSH密钥

$ ssh-keygen -t rsa -b 4096 -C "web@github.com"

3.在SSH代理级别添加密钥

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa_github

4. 将新密钥添加到Github回购。

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

Git远程添加原点your_ssh_link_from_github

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

在执行此操作之前,请确保您拥有对回购的写权限。如果您仍然得到错误,请执行以下操作:

Generate a personal access token from your account from Settings > Developer Settings > Personal Access tokens. Keep the token safe somewhere. Go to your repository and run the following: git remote rm origin Then add a new origin along with your username: git remote add origin https://USERNAME@github.com/REPOSITORY_LINK.git Now when you push the code, a prompt will show up asking for your password or personal access token. Paste the token that we generated in the first step in the field, and we're done.

我在一台MAC上遇到了同样的问题,试图从我以前连接到的一个私人回购中提取。

我通过在回购url中包含我的用户名来解决这个问题:

git remote set-url origin https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git

然后我从回购中提取了数据。

对于一个你想克隆的新回购:

git clone https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git    

它会提示你输入那个账户的密码,然后你就可以去了。