`git fetch origin` 和 `git remote update origin` 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2688251/
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
What is the difference between `git fetch origin` and `git remote update origin`?
提问by Norman Ramsey
In response to a question about pulling one commit at a time from a git repository, I was recommended to use git remote update
instead of git fetch
. I have read both man pages but cannot say I understood either in its entirety.
在回答关于拉一个承诺从一个Git仓库一个时间早晚的问题,我建议使用git remote update
来代替git fetch
。我已经阅读了两个手册页,但不能说我完全理解。
Can anyone explain to me how git fetch origin
and get remote update origin
behave differently?
任何人都可以向我解释如何git fetch origin
和get remote update origin
行为不同吗?
回答by Cascabel
It makes no difference when used like this.
像这样使用时没有区别。
remote update
is a very high-level command - it supports grouped remotes (remotes.<group> = <list>
), and updating all remotes (except those with remote.<name>.skipDefaultUpdate
set), but not any of the more specific options of fetch. Under the hood, though, it does the exact same thing as fetch with the default options.
remote update
是一个非常高级的命令 - 它支持分组遥控器 ( remotes.<group> = <list>
),并更新所有遥控器(除了那些带有remote.<name>.skipDefaultUpdate
set 的遥控器),但不支持任何更具体的 fetch 选项。但是,在幕后,它与使用默认选项的 fetch 完全相同。
The answer recommending remote update
instead of git fetch was actually recommending it without a remote name, just for the sake of fetching all, not just the one named as an argument. This is equivalent to git fetch --all
.
推荐remote update
而不是 git fetch的答案实际上是在没有远程名称的情况下推荐它,只是为了获取所有内容,而不仅仅是作为参数命名的那个。这相当于git fetch --all
.
I should add the caveat that fetch and remote update didn't actually use the same codepath until v1.6.6.1 (released December 23 2009). Even before that, though, they did essentially the same thing, just using different code (possibly behaving slightly differently in corner cases, but I can't think of any off the top of my head).
我应该补充一点,在 v1.6.6.1(2009 年 12 月 23 日发布)之前,fetch 和远程更新实际上并没有使用相同的代码路径。尽管如此,即使在此之前,他们也做了本质上相同的事情,只是使用了不同的代码(在极端情况下的行为可能略有不同,但我想不出任何问题)。