添加了不正确的Git遥控器;无法删除它或用另一个遥控器覆盖它

blu*_*ion 1 git github git-remote

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

$ git remote add upstream https://github.com/hackreactor/HRATX24-javascript-koans.git
Run Code Online (Sandbox Code Playgroud)

我这样做是为了防止分叉的原始(上游)存储库中的代码发生更改,更改也将上传并反映在我的fork中。我不确定该命令是否设置了远程原点,因为我仍处于熟悉git的早期阶段,但是运行时

$ git remote -v
Run Code Online (Sandbox Code Playgroud)

git告诉我,我的起源是:https : //github.com/hackreactor/HRATX24-javascript-koans.git。我试着删除此遥控器并覆盖它,但是没有用。尝试删除它时,我得到错误消息-致命:没有这样的远程,并且当我尝试覆盖它时,我得到了错误消息-致命:远程源已经存在。这两个错误消息似乎是矛盾的,所以我不确定如何继续。谁能帮助我了解正在发生的事情以及如何让git将遥控器重置为正确的网址?

这是我运行的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.
Run Code Online (Sandbox Code Playgroud)

mil*_*ner 6

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

另外,您也可以像这样更新遥控器的URL:

git remote set-url origin https://github.com/BLuEScioN/HRATX24-javascript-koans.git
Run Code Online (Sandbox Code Playgroud)