阅读(3465) (0)

GitHub 删除远程

2020-08-19 14:42:53 更新

使用 git remote rm 命令可从仓库中删除远程 URL。

git remote rm 命令使用一个参数:

  • 远程名称,例如 destination

示例

以下示例假设您使用 HTTPS 克隆,即推荐使用的方法。

$ git remote -v
## 查看当前远程
> 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
## 删除远程
$ git remote -v
## 验证其已删除
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)

git remote rm 不会从服务器中删除远程仓库。 它只是从本地仓库中删除远程及其引用。

疑难解答

当您尝试删除远程时可能会遇到以下错误。

无法删除配置部分 'remote.[name]'

此错误表示您尝试删除的远程不存在:

$ git remote rm sofake
> error: Could not remove config section 'remote.sofake'

检查您是否正确键入了远程仓库的名称。

延伸阅读