我已经检查了很多 stackoverflow,试图找出为什么我会收到这个错误,因为我在 github 上确实有一个关于我想要推送的内容的存储库。我什至重新生成了我的 ssh key 并将其添加到 github。我还看到:
Please make sure you have the correct access rights
并且存储库存在。
当我尝试远程添加存储库时,我看到:
$ git remote add origin <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84e3edf0c4e3edf0ecf1e6aae7ebe9" rel="noreferrer noopener nofollow">[email protected]</a>:<username>/<reponame>.git
> fatal: remote origin already exists.
$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
然后我收到错误
当我尝试时
ssh -T <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f6919f82b6919f829e8394d895999b" rel="noreferrer noopener nofollow">[email protected]</a>
我看到正确的用户名
不知道还可以尝试什么。
最佳答案
如果您已经输入
$ git remote add origin <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="baddd3cefaddd3ced2cfd894d9d5d7" rel="noreferrer noopener nofollow">[email protected]</a>:<username>/<reponame>.git
你不能再输入它,因为origin现在已经存在了。 它会响应
fatal: remote origin already exists.
但是链接到源的地址可能是错误的。 尝试输入
$ git remote remove origin
并输入
$ git remote add origin <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="76111f0236111f021e03145815191b" rel="noreferrer noopener nofollow">[email protected]</a>:<username>/<reponame>.git
再次。
然后输入
$ git push origin master
如果地址和 SSH key 都正确,则可能有效。
关于git - 使用 git 时未发现 Repo fatal error 且无法推送到 github,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54301340/