问题
I rebased my commits onto the integration branch, then added some commits. Then I found the integration branch has new commits so I decided to rebase again. But to my surprise this time rebase had quite some conflicts.
I further checked where did those conflicts come from and was surprised again. The conflicts were actually the newer commit modified the old one on the integration branch that I already rebased the first time! See the following picture.
And if I use merge to get the new commits no problem at all!
In the integration branch 91ba229 & c4a3755 both modified the same file.
The first time rebase The second time rebase since I want to get commits 5997579 & ed2d5b2, conflicts! Because c4a3755 was applied again and conflicted with the result I got from 91ba229 !. But why?
Why did git apply commit c4a3755 again?
BTW, the blue line is my own branch, I didn't push it to the remote server and I only did what I described in my own branch.
--------------------- update -------------------
I found some clue but I still need some input. So after 1st rebase, my commits did not sit on top of int branch, but the other way around, i.e. the int branch commits sit on top of my commits. I have not figure out why, but it is the reason for the conflicts on the 2nd rebase.
Because instead of letting int branch commits become my base, 2 branches still had the old base. Then when applying the 2nd rebase, all the commits from int branch were applied again. Hence the conflicts.
来源:https://stackoverflow.com/questions/49894883/rebase-once-commit-some-changes-then-rebase-again-some-unexpected-conflicts