【问题标题】:How do I remove an invalid remote I added in Git?如何删除我在 Git 中添加的无效遥控器?
【发布时间】:2011-04-20 12:51:40
【问题描述】:

这是我解雇的那一行:

git remote add Nakor git://github.com.nakor/CherryTomato.git

我犯了一个错误,命令应该是:

git remote add Nakor git://github.com/nakor/CherryTomato.git

当我尝试运行第二个命令时,我得到了这个错误:

fatal: Remote Nakor already exists.

这是可以理解的。如何编辑远程Nakor 指向的端点?

【问题讨论】:

    标签: git


    【解决方案1】:

    来自github帮助Removing a remote

    git remote -v
    # View current remotes
    origin  https://github.com/OWNER/REPOSITORY.git (fetch)
    origin  https://github.com/OWNER/REPOSITORY.git (push)
    destination  https://github.com/FORKER/REPOSITORY.git (fetch)
    destination  https://github.com/FORKER/REPOSITORY.git (push)
    
    git remote rm destination
    # Remove remote
    git remote -v
    # Verify it's gone
    origin  https://github.com/OWNER/REPOSITORY.git (fetch)
    origin  https://github.com/OWNER/REPOSITORY.git (push)
    

    【讨论】:

      【解决方案2】:

      你可以使用 git remote 的set-url 子命令:

      git remote set-url Nakor git://github.com/nakor/CherryTomato.git
      

      【讨论】:

      • 这个答案有错别字 - 你不应该在 --set-url 中有 -- - 它只是 git remote set-url Nakor git://github.com/nakor/CherryTomato.git
      • 这是新的做法: git remote set-url []
      【解决方案3】:

      当一切都失败时:

      git config --edit
      

      在……

      [remote "Nakor"]
      

      ...编辑行...

          url = git://github.com.nakor/CherryTomato.git
      

      【讨论】:

      • 它打开了一个 Vim 终端,所以现在我有 两个 问题。 :D 有什么方法可以在普通文本编辑器上编辑它?我在 Windows 7 上。
      • 很遗憾听到这个消息 (Windows)。请参阅this question,了解如何在 Windows 上配置您的编辑器。
      • P.S: Vim 是一个normal 文本编辑器...你应该找个时间试试看!
      • 我几乎不会称 Vim 为普通的文本编辑器(在普通的英语意义上)。另外,我使用 Emacs。 :)
      【解决方案4】:

      git remote --help 说明一切。在这种情况下,请使用git remote set-url ...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-17
        • 2012-10-09
        • 2017-03-17
        • 2014-03-12
        • 2012-09-06
        • 1970-01-01
        相关资源
        最近更新 更多