我该如何在Git中删除一个无效的远程仓库?

14

这是我输入的代码行:

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指向的端点?

4个回答

21

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

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

3
这个答案有一个打字错误 - 在 --set-url 中不应该有 -- - 应该是 git remote set-url Nakor git://github.com/nakor/CherryTomato.git - Mark Longair
这是新的做法:git remote set-url <name> <newurl> [<oldurl>]。 - BringBackCommodore64

9
当其他方法都失败时:
git config --edit

Under...

[remote "Nakor"]

...编辑这一行...

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

它打开了一个 Vim 终端,所以现在我有两个问题。:D 有没有办法在普通文本编辑器上编辑这个?我使用的是 Windows 7。 - Only Bolivian Here
1
很抱歉听到这个(Windows)消息。请参考此问题了解如何在Windows上配置您的编辑器。 - johnsyweb
PS:Vim是一款普通的文本编辑器...你应该有机会试试它! - johnsyweb
我几乎不会把Vim称为普通的文本编辑器(在常规英语意义上)。另外,我使用Emacs。 :) - Only Bolivian Here

5

来自 Github 帮助 移除远程仓库:

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)

1

git remote --help告诉你一切。在这种情况下,使用git remote set-url ...


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接