Git rebase local vs git pull --rebase origin
1. git fetch origin
and git rebase master
will apply changes from F1
to local master
branch. Assume your commit history looks like below at first (the remote master
branch has commit J
in remote):
A---B---C---D---E master
\
F---G---H F1
When you execute git fetch origin
and git rebase master
, even though origin/master
points to J
, it will only rebase F1
branch on the top of local master
branch (commit E
as the graph):
A---B---C---D---E(master)---J origin/master
\
F---G---H F1
2. The command git pull --rebase origin master
will pull changes from remote master
branch at first, then rebase current branch F1
on the top of it:
A---B---C---D---E---J master,origin/master
\
F---G---H F1
In a word, if local master
branch is sync with remote master
branch, these two ways have the same result (rebase F1
branch on the top of master branch). If remote master
branch has new commit(s) which is(are) not exist on local master
branch, the results are different (one rebases on local master
branch, the other rebase on origin/master
branch).