Git 从本地存储库中删除上游
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19801455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git removing upstream from local repository
提问by user2603138
I am working with a ruby on rails application and I am trying to sync a fork. It is worth mentioning that I am also on a Mac. I committed the following action:
我正在使用 ruby on rails 应用程序,我正在尝试同步一个 fork。值得一提的是,我也在 Mac 上。我进行了以下操作:
$ git remote -v
to get a view of my local repository. I messed up when trying to go upstream
:
查看我的本地存储库。我在尝试去的时候搞砸了upstream
:
$ git remote add upstream https://github.com/foo/repo.git
When I should have capitalized Foo:
当我应该大写 Foo 时:
$ git remote add upstream https://github.com/Foo/repos.git
The question is how do I remove the upstream
because every time I try and change this it comes back with creating a fatal
error?
问题是我如何删除 ,upstream
因为每次我尝试更改它时都会产生fatal
错误?
回答by bmacnaughton
Using git version 1.7.9.5 there is no "remove" command for remote. Use "rm" instead.
使用 git 版本 1.7.9.5 没有远程的“删除”命令。改用“rm”。
$ git remote rm upstream
$ git remote add upstream https://github.com/Foo/repos.git
or, as noted in the previous answer, set-url works.
或者,如上一个答案所述, set-url 有效。
I don't know when the command changed, but Ubuntu 12.04 shipped with 1.7.9.5.
我不知道命令何时更改,但 Ubuntu 12.04 随附 1.7.9.5。
回答by Bert F
git remote manpage is pretty straightforward:
git remote manpage 非常简单:
Use
用
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
or just update the URL directly:
或者直接更新 URL:
$ git remote set-url upstream https://github.com/Foo/repos.git
or if you are comfortable with it, just update the .git/config directly - you can probably figure out what you need to change (left as exercise for the reader).
或者如果您对它感到满意,只需直接更新 .git/config - 您可能会弄清楚需要更改的内容(留给读者作为练习)。
...
[remote "upstream"]
fetch = +refs/heads/*:refs/remotes/upstream/*
url = https://github.com/foo/repos.git
...
===
===
* Regarding 'git remote rm' vs 'git remote remove' - this changed around git 1.7.10.3/ 1.7.12 2- see
* 关于 'git remote rm' 与 'git remote remove' - 这在 git 1.7.10.3/ 1.7.12 2左右发生了变化- 见
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.
回答by rodelm
$ git remote remove <name>
ie.
IE。
$ git remote remove upstream
that should do the trick
这应该够了吧
回答by Ashwin Balasundaram
In git version 2.14.3,
在 git 版本 2.14.3 中,
You can remove upstream using
您可以使用删除上游
git branch --unset-upstream
The above command will also remove the tracking stream branch, hence if you want to rebase from repository you have use
上面的命令还将删除跟踪流分支,因此如果您想从您使用的存储库中变基
git rebase origin master
instead of git pull --rebase
代替 git pull --rebase