除了生成的 git 树结构之外,git pull 与 git fetch + git rebase 之间是否有任何重要区别?

Aside from the resulting git tree structure, are there any important differences between git pull vs git fetch + git rebase?

我曾在一个开发团队工作过,该团队更喜欢使用 git fetch 然后 git rebase 的方法,而不是 git pull 的方法,然后再 git 推送任何更改以避免合并冲突。

除了视觉树结构的不同,还有什么具体原因吗?根据 http://mattsnider.com/git-rebase-versus-git-pull/ fetch & rebase

"will produce a cleaner history, without extraneous merge commits"

但是在这两种方法之间还有其他选择其中一种的理由吗?

git pull = git fetch + git merge

git pull --rebasegit pull -r= git fetch + git rebase

不多不少 ;-) 没有魔法。 所以你可以做第二个。

在两个不同的步骤中执行 fetch 然后 rebase 的主要优点是第一个不会修改您的本地分支(绝对没有风险),因此您每次都可以这样做(您甚至可以创建一个任务 运行 定期)。

获取后,您可以查看历史记录,将其与您的提交进行比较,然后决定您想要做什么以及何时...