【问题标题】:Added incorrect Git remote; can't remove it or overwrite it with another remote添加了不正确的 Git 远程;无法删除它或用另一个遥控器覆盖它
【发布时间】:2017-03-17 15:45:16
【问题描述】:

我错误地为我的 git 存储库添加了错误的远程源。我从未明确设置我的 repo 的远程来源。我认为它必须是默认设置的,在设置远程源之前,我运行了:

$ git remote add upstream https://github.com/hackreactor/HRATX24-javascript-koans.git

我这样做是为了万一我派生的原始(上游)存储库中的代码发生更改,这些更改也会被上传并反映在我的派生中。我不能确定这个命令是否设置了我的远程来源,因为我仍处于熟悉 git 的早期阶段,但是当运行时

$ git remote -v

git 告诉我我的来源是:https://github.com/hackreactor/HRATX24-javascript-koans.git。我试过删除这个遥控器并覆盖它,但都不管用。尝试删除它时,我收到错误消息 - 致命:没有这样的远程,当我尝试覆盖它时,我收到错误消息 - 致命:远程来源已经存在。这两个错误信息似乎是矛盾的,所以我不知道如何进行。谁能帮助我更好地了解发生了什么以及如何让 git 将我的遥控器重置为正确的 url?

这是我运行的 git 命令以及 git 为它们提供的输出:

$ git remote -v
origin  https://github.com/hackreactor/HRATX24-javascript-koans.git (fetch)
origin  https://github.com/hackreactor/HRATX24-javascript-koans.git (push)
upstream        https://github.com/hackreactor/HRATX24-javascript-koans.git (fetch)
upstream        https://github.com/hackreactor/HRATX24-javascript-koans.git (push)

$ git remote rm https://github.com/hackreactor/HRATX24-javascript-koans.git
fatal: No such remote: https://github.com/hackreactor/HRATX24-javascript-koans.git

$ git remote add origin  https://github.com/BLuEScioN/HRATX24-javascript-koans.git
fatal: remote origin already exists.

【问题讨论】:

    标签: git github git-remote


    【解决方案1】:

    git remote rm 将远程的名称(在本例中为 origin)作为其命令。

    或者,您也可以像这样更新远程的 URL:

    git remote set-url origin https://github.com/BLuEScioN/HRATX24-javascript-koans.git
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-09
      • 2012-08-04
      • 2017-01-08
      • 2012-10-09
      • 1970-01-01
      • 2022-07-02
      相关资源
      最近更新 更多