0

So I have branch master and RC branches. When I made a pull request from master to RC, it showed a lot of conflicts. I tried rebasing on RC first (locally) and no rebase conflicts showed.

When I tried merging locally, I also got conflicts. Why is that the case? What can make rebase works with no conflicts but not merge?

blenddd
  • 345
  • 1
  • 6
  • 15
  • Do you have rerere enabled (`git config --get rerere.enabled`) ? This can be one reason why a conflict can be solved automatically in one case, and not in the other. – LeGEC Oct 11 '17 at 12:32

1 Answers1

1

I think the most likely reason would be that a commit has been cherry-picked from one branch involved in the merge to the other. If rebase detects that a commit it's about to rewrite applies the same textual changes as a commit already included in the new base, then it skips that commit. (There's probably something inexact about that explanation, but it's roughly right...)

So if you have

x -- A -- B -- C <--(master)
 \
  D -- A' -- E <--(branch)

where A' makes the same changes to D that A made to x (perhaps it was cherry-picked, or rebased, or squash merged...), then

git rebase branch master

would rewrite D and E, skipping A'. But

git checkout master
git merge branch

would not look at the individual commits, so you could get conflicts due to the changes in A'.

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52
  • See also my answer to https://stackoverflow.com/q/44546974/1256452 (includes this case, and two others) – torek Oct 11 '17 at 17:00