Trial to better explain the difference between git pull --rebase
and git rebase
incorporating the comments of @noam-gal and @dnuttle
Simple situation: If the history of the upstream wasn't rewritten, git pull --rebase
is git fetch
+ git rebase
.
Advanced situation: If the history of the upstream was rewritten (f.ex. due to a rebase or amend of already pushed commits), git pull --rebase
is git fetch
+ a rebase of the local changes on the remote branch (i.e. git rebase --onto <default_remote>/<current_branch> a <current_branch>
, with a
the most recent upstream commit that is a parent of your local current branch). Advantage of this approach is that changed upstream commits don't result in conflicts with the old version of these commits.
References
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.