git - 使用 git 时未发现 Repo fatal error 且无法推送到 github

标签 git github ssh ssh-keygen

我已经检查了很多 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/

相关文章:

git 从常规哈希中获取短哈希

Git命令将当前文件保存在临时分支中而不提交到master

git - fatal : unable to access : Failed to connect to bitbucket. 组织端口 443:连接超时

git维护同一个项目的两个版本,每个版本都有不同的用户

ssh - 如何使用 Sublime Text 3 打开多个远程文件?

r - 从 Atlassian Stash 安装 R 包

json - 如何在 Jenkins 中处理 github webhook 有效负载?

git - 推送到 GitHub 存储库时出现 "Please make sure all files only have LF endings"错误

linux - Putty 作为 cmd 和 sh 之间的接口(interface)

linux - 使用 shell 脚本 ssh 到不同的节点