git - 关于 git pull --rebase 的困惑

标签 git 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 之后,教程 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.

关于git - 关于 git pull --rebase 的困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57568638/

相关文章:

Git: merge 背后的变化

不在目录中时的 Git 标记状态

git rebase 由于空格错误而失败

git - 为什么 git rebase 的 merge 冲突通常比 merge 少?

git - git 项目中手动重命名文件的修复方法是什么?

git - 在 git 中恢复 merge 提交后强制 merge

git - 如何用 Git 将一个分支一分为二?

git - git rebase --onto --preserve-merges再现了我已经在 merge 中解决的冲突

git - 检查开发分支是否已 merge 到功能分支?

github - 压缩、 rebase 、重置 --soft 如何影响 github 贡献页面?