关于 git pull --rebase 的困惑
Confusion about git pull --rebase
根据教程我发现:https://www.atlassian.com/git/tutorials/syncing/git-pull
git pull --rebase 将提交附加到本地树。
A - B - C (origin/master)
/
D - E - F - G (local master)
在 git pull --rebase on local tutorial calims 之后它应该看起来像:
A - B - C (origin/master)
/
D - E - F - G - A - B - C (local master)
我希望它是这样的:
A - B - C (origin/master)
/
D - A - B - C - E' - F' - G' (local master)
我错过了什么吗?或许他们错了?
你是对的。
该页有误,不仅是图表,还有附带的文字:
In this diagram, we can now see that a rebase pull does not create the new H commit. Instead, the rebase has copied the remote commits A--B--C and appended them to the local origin/master commit history.
手册页更清楚:
-r, --rebase[=false|true|preserve|interactive]
When true, rebase the current branch on top of the upstream branch after
fetching. If there is a remote-tracking branch corresponding to the
upstream branch and the upstream branch was rebased since last fetched,
the rebase uses that information to avoid rebasing non-local changes.
如果你有这个。
A - B - C (origin/master)
/
D - E - F - G (master)
在 git pull --rebase
之后,假设没有获取新的提交,您将拥有这个。
D - A - B - C [origin/master]
\
E' - F' - G' [master]
E、F 和 G 在 origin/master
之上重播。
注意只有一个 A、B 和 C。远程和本地分支都共享同一个提交树。
根据教程我发现:https://www.atlassian.com/git/tutorials/syncing/git-pull
git pull --rebase 将提交附加到本地树。
A - B - C (origin/master)
/
D - E - F - G (local master)
在 git pull --rebase on local tutorial calims 之后它应该看起来像:
A - B - C (origin/master)
/
D - E - F - G - A - B - C (local master)
我希望它是这样的:
A - B - C (origin/master)
/
D - A - B - C - E' - F' - G' (local master)
我错过了什么吗?或许他们错了?
你是对的。
该页有误,不仅是图表,还有附带的文字:
In this diagram, we can now see that a rebase pull does not create the new H commit. Instead, the rebase has copied the remote commits A--B--C and appended them to the local origin/master commit history.
手册页更清楚:
-r, --rebase[=false|true|preserve|interactive]
When true, rebase the current branch on top of the upstream branch after fetching. If there is a remote-tracking branch corresponding to the upstream branch and the upstream branch was rebased since last fetched, the rebase uses that information to avoid rebasing non-local changes.
如果你有这个。
A - B - C (origin/master)
/
D - E - F - G (master)
在 git pull --rebase
之后,假设没有获取新的提交,您将拥有这个。
D - A - B - C [origin/master]
\
E' - F' - G' [master]
E、F 和 G 在 origin/master
之上重播。
注意只有一个 A、B 和 C。远程和本地分支都共享同一个提交树。