git rebase upstream/master vs git pull --rebase upstream master
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15602037/
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 rebase upstream/master vs git pull --rebase upstream master
提问by Dennis
Is there a difference between git rebase upstream/master
and git pull --rebase upstream master
, and if so, what? The remote could be any remote, not necessarily upstream.
有没有之间的差异git rebase upstream/master
和git pull --rebase upstream master
,如果是这样,是什么?遥控器可以是任何遥控器,不一定是上游。
回答by VonC
The git pull --rebase
will fetch (git fetch
)first, updating upstream/master
commits.
该git pull --rebase
会取(git fetch
)第一,更新upstream/master
的提交。
If you just rebase withoutfirst updating upstream/master
, you won't get the same result.
如果您只是在没有先更新的情况下重新设置基准upstream/master
,您将不会得到相同的结果。
I illustrate it in "master
branch and 'origin/master
' have diverged, how to 'undiverge' branches'?"
我说明了它的“master
分支和‘ origin/master
’有分歧,如何‘undiverge’分支?”
SnakEmentions in the commentsthat git pull --rebase
isn't exactlygit fetch && git rebase origin/master
.
See "what does "git pull --rebase
" do?"
SnakeE在评论中提到的git pull --rebase
不完全是git fetch && git rebase origin/master
.
看看“”是git pull --rebase
做什么的?”
(origin/master)
|
A--B--C (master)
\
B'--D (actual origin/master after changing B and force pushing)
What git pull --rebase
does, in this case, is:
是什么git pull --rebase
呢,在这种情况下,就是:
git fetch origin
git rebase --onto origin/master B master
Here:
这里:
- origin/master is the new updated
origin/master
(B'
) B
is the oldorigin/master
(before a fetch updated it)master
is the branch to replay on top oforigin/master
- origin/master 是新的更新
origin/master
(B'
) B
是旧的origin/master
(在 fetch 更新它之前)master
是重播的分支origin/master
This differs from git fetch
+ git rebase origin/master
in that the pull --rebase
command tries to find out which commits are reallyyour local ones, and which had come from upstream in an earlier fetch.
这与git fetch
+ 的不同之处git rebase origin/master
在于该pull --rebase
命令试图找出哪些提交确实是您的本地提交,哪些提交来自上游的早期获取。
To do this, it looks at the reflog of the remote tracking branch (
origin/master
, in this case). This reflog represents the tips of successivegit fetch
operations onorigin
, in "most recent first" order.For each reflog entry, (
origin/master@{1}
, then...{2}
, and so on) it checks if that commit is an ancestor of the current branch headmaster
. As soon as it finds one, it picks it as the starting point for the rebase (B
in the example above).
为此,它查看远程跟踪分支的引用日志(
origin/master
在本例中为 )。此 reflog 表示对 的连续git fetch
操作的提示origin
,按“最近在先”的顺序。对于每个 reflog 条目, (
origin/master@{1}
、 then...{2}
等等) 它会检查该提交是否是当前分支 head 的祖先master
。一旦找到一个,它就会选择它作为 rebase 的起点(B
在上面的例子中)。