Git从本地存储库中删除上游

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Git从本地存储库中删除上游相关的知识,希望对你有一定的参考价值。

我正在使用ruby on rails应用程序,我正在尝试同步一个fork。值得一提的是,我也在Mac上。我做了以下行动:

$ git remote -v

获取我的本地存储库的视图。我试图去upstream时搞砸了:

$ git remote add upstream https://github.com/foo/repo.git

什么时候我应该大写Foo:

$ git remote add upstream https://github.com/Foo/repos.git

问题是我如何删除upstream,因为每次我尝试更改它时会回来创建一个fatal错误?

答案

使用git版本1.7.9.5,远程没有“删除”命令。请改用“rm”。

$ git remote rm upstream
$ git remote add upstream https://github.com/Foo/repos.git

或者,如前面的答案中所述,set-url有效。

我不知道命令何时更改,但Ubuntu 12.04随1.7.9.5一起发货。

另一答案

git远程联机帮助页非常简单:

使用

Older (backwards-compatible) syntax:
$ git remote rm upstream
Newer syntax for newer git versions: (* see below)
$ git remote remove upstream

Then do:    
$ git remote add upstream https://github.com/Foo/repos.git

或者直接更新URL:

$ git remote set-url upstream https://github.com/Foo/repos.git

或者如果你对它感到满意,只需直接更新.git / config - 你可以找出你需要改变的东西(留给读者练习)。

...
[remote "upstream"]
    fetch = +refs/heads/*:refs/remotes/upstream/*
    url = https://github.com/foo/repos.git
...

===

*关于'git remote rm'与'git remote remove' - 这改变了围绕git 1.7.10.3 / 1.7.12 2 - 请参阅

https://code.google.com/p/git-core/source/detail?spec=svne17dba8fe15028425acd6a4ebebf1b8e9377d3c6&r=e17dba8fe15028425acd6a4ebebf1b8e9377d3c6

Log message

remote: prefer subcommand name 'remove' to 'rm'

All remote subcommands are spelled out words except 'rm'. 'rm', being a
popular UNIX command name, may mislead users that there are also 'ls' or
'mv'. Use 'remove' to fit with the rest of subcommands.

'rm' is still supported and used in the test suite. It's just not
widely advertised.
另一答案
$ git remote remove <name>

即。

$ git remote remove upstream

这应该够了吧

另一答案

在git版本2.14.3中,

您可以使用删除上游

git branch --unset-upstream

上面的命令也将删除跟踪流分支,因此如果您想要从您使用的存储库进行rebase

git rebase origin master 

而不是git pull --rebase

以上是关于Git从本地存储库中删除上游的主要内容,如果未能解决你的问题,请参考以下文章

sh 从git存储库中删除所有标记(本地和远程)

从 Git 存储库中删除所有标签

如何从 git bash 屏幕中删除文件并从存储库中删除该文件? [复制]

从 Heroku Git 存储库中删除密钥

从存储库中删除文件但将其保留在本地

如何从 git 存储库中删除文件而不实际删除文件 [重复]