I would like to provide a different perspective on what "git pull --rebase" actually means, because it seems to get lost sometimes.
(我想提供一个关于“git pull --rebase”实际意味着什么的不同观点,因为它似乎有时会迷失。)
If you've ever used Subversion (or CVS), you may be used to the behavior of "svn update".
(如果您曾经使用过Subversion(或CVS),您可能会习惯“svn update”的行为。)
If you have changes to commit and the commit fails because changes have been made upstream, you "svn update". (如果您有提交更改并且提交失败,因为已在上游进行了更改,则您将“svn update”。)
Subversion proceeds by merging upstream changes with yours, potentially resulting in conflicts. (Subversion通过将上游更改与您的上游进行合并来进行,可能会导致冲突。)
What Subversion just did, was essentially "pull --rebase".
(Subversion刚刚做了什么,基本上是“拉动 - 基础”。)
The act of re-formulating your local changes to be relative to the newer version is the "rebasing" part of it. (将本地更改重新制定为相对于较新版本的行为是其“重新定位”部分。)
If you had done "svn diff" prior to the failed commit attempt, and compare the resulting diff with the output of "svn diff" afterwards, the difference between the two diffs is what the rebasing operation did. (如果你在失败的提交尝试之前完成了“svn diff”,并且之后将得到的diff与“svn diff”的输出进行比较,那么两个差异之间的差异就是变基操作所做的。)
The major difference between Git and Subversion in this case is that in Subversion, "your" changes only exist as non-committed changes in your working copy, while in Git you have actual commits locally.
(在这种情况下,Git和Subversion之间的主要区别在于,在Subversion中,“您的”更改仅作为工作副本中的非提交更改存在,而在Git中,您在本地实际提交。)
In other words, in Git you have forked the history; (换句话说,在Git中你已经分享了历史;)
your history and the upstream history has diverged, but you have a common ancestor. (你的历史和上游历史有分歧,但你有一个共同的祖先。)
In my opinion, in the normal case of having your local branch simply reflecting the upstream branch and doing continuous development on it, the right thing to do is always "--rebase", because that is what you are semantically actually doing .
(在我看来,在正常情况下让你的本地分支只是反映上游分支并对其进行持续开发,正确的做法总是“--rebase”,因为这是你在语义上实际做的事情 。)
You and others are hacking away at the intended linear history of a branch. (你和其他人正在破坏分支的预期线性历史。)
The fact that someone else happened to push slightly prior to your attempted push is irrelevant, and it seems counter-productive for each such accident of timing to result in merges in the history. (事实上,其他人在您尝试推动之前碰巧略微推动是无关紧要的,并且对于每次这样的事故导致合并的历史事件而言似乎适得其反。)
If you actually feel the need for something to be a branch for whatever reason, that is a different concern in my opinion.
(如果你因为某种原因确实觉得需要某个分支,那么我认为这是一个不同的问题。)
But unless you have a specific and active desire to represent your changes in the form of a merge, the default behavior should, in my opinion, be "git pull --rebase". (但除非您有特定且积极的愿望以合并的形式表示您的更改,否则默认行为应该是“git pull --rebase”。)
Please consider other people that need to observe and understand the history of your project.
(请考虑需要观察和了解项目历史的其他人。)
Do you want the history littered with hundreds of merges all over the place, or do you want only the select few merges that represent real merges of intentional divergent development efforts? (您是否希望历史上散布着数以百计的合并,或者您是否只想要选择少数合并来代表有意的分歧开发工作的真正合并?)