Suppose I have feature branch locally, FB. FB has diverged from master at commit, say CC. FB has several commits more, say FBC1,FBC2.FB is pushed to remote repository, and then merged into master. So remote master has FBC1,FBC2, and then few more commits prior and after.
Now if I pull remote commits to my local, so that my local master is now having CC-MC1-MC2-FBC1-FBC2-MC3-MC4, while FB has CC-FBC1-FBC2. So both master and FB have commits FBC1,FBC2.
Now if I rebase master on FB, then what would be behaviour?
tl;dr: It will do what rebase does, which is replay all (non-merge) commits that are in the source branch but not in the target branch, on top of the target branch.
First let's consider the opposite of what you asked: What if we rebase FB
onto master
? Every commit in FB
is already in master
, so it will place 0 commits on top of master
. The result is FB
will be reset to look exactly like master
.
Now for your question, if we rebase master
onto FB
, every (non-merge) commit that is on master
but not also in FB
, will be replayed on top of FB
. Your example only shows merge commits, but presumably those merge commits before and after the merge commit for branch FB
brought in some other commits with the merge? In that case, all of those commits would be replayed without their corresponding merge commits and the graph would be modified to become linear after commit FB2. (This assumes there are no conflicts and the rebase succeeds.)
To see which commits would be replayed and subsequently "rearranged" on master
, you can run this command:
git log FB..master --no-merges
That shows all the commits in master
that aren't in FB
, minus the merge commits.