【问题标题】:fatal: remote origin already exists. , fatal: No such remote:致命:远程来源已经存在。 ,致命:没有这样的遥控器:
【发布时间】:2019-11-22 20:48:33
【问题描述】:

我试过了

git remote add origin https://github.com/rezaee/confusion-last.git

得到了

fatal: remote origin already exists.

然后尝试

git push -u origin master

但是得到了:

warning: redirecting to https://github.com/rezaee/confusion.git/
To http://github.com/rezaee/confusion.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'http://github.com/rezaee/confusion.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

所以我尝试了

git remote remove https://github.com/rezaee/confusion-last.git

但是得到了

fatal: No such remote: 'https://github.com/rezaee/confusion-last.git'.

这怎么可能?

【问题讨论】:

    标签: github git-push git-remote


    【解决方案1】:

    你可以试试下面的 git 命令:

    在 git 初始化后,你可以添加 repo,然后尝试通过以下命令从 git 站点设置 url

    git remote set-url origin
    

    一旦来源设置尝试你的回购网址

    git remote set-url origin [https: your repo link from git]
    

    检查你设置的url是否存在于master中

    git remote -v
    

    现在你可以将你的 repo 推送到 github

    git push -u origin master
    

    有时 set-url 在 add don't 时会起作用,所以试试上面的这些命令。

    【讨论】:

    • 欢迎来到 Stack Overflow。在 Stack Overflow 上不鼓励仅使用代码的答案,因为它们没有解释它是如何解决问题的。请编辑您的答案以解释每个命令的作用以及它如何解决问题,以便它对 OP 以及其他有类似问题的用户有用。
    【解决方案2】:

    这是可能的,因为git remote remove 寻找一个远程别名name不是实际的 URL。

    git remote remove origin
    

    那会奏效的。

    但是,您的遥控器已设置为另一个 URL (see git remote -get-url origin)。
    要更改它 不必删除它:

    git remote set-url origin https://github.com/rezaee/confusion-last.git
    

    【讨论】:

      猜你喜欢
      • 2014-10-14
      • 2012-06-09
      • 2019-04-21
      • 2013-06-26
      • 1970-01-01
      • 2018-03-19
      • 1970-01-01
      • 2019-07-08
      相关资源
      最近更新 更多