Consider following scenario:
- I checked out a branch from master
- I made some commits
- I merged updated master
- I made some more commits
- Now I want rebase commits from point 4 so that commits from point 2 are not affected.
So if I have initially:
(1) (2)
x--x--x--x--x--x--x master
\ \
y--y--Y--y--y dev
(2)(3) (4)
I want to get:
(1) (2)
x--x--x--x--x--x--x master
\ \
y--y--------Y'--y'--y' dev
(2) (5) (5)
If I just do git rebase master
it will rebase commits both from 2 and from 4 and delete merge from 3. It's not what I want.
There is also option to do git merge master
, then git rebase -i -p
before the merge commit from 3 and move the last merge after the merge from 3 and do fixup/squash it into the merge from 3. Update: it does not work that easy. Git refuses to squash two merges. This problem: git rebase interactive: squash merge commits together .