Search code examples
gitopen-sourcegit-mergesapui5git-fork

Merge results in merge-conflicts to files I didn't alter


I have been working with a fork of SAP's OpenUI5 repository for a while and would like to merge in the latest changes from another (more recent) release branch. In essence, I want to "upgrade" my fork.

My fork point was aa08b45865b8db4457bc6c626754c58230811b43 which points to a commit reachable by the rel-1.28 release branch.

I started my "fork" off a release branch, rather than master, because I was worried that working off of master would be unstable and have commits that overlap multiple releases.

My upgrade target is 1.34.6 which is pointed to by cb4d1be36087ed7f1dfbde44884782774fceb51b.

The ultimate command that I need to run is effectively:

git checkout aa08b45        # my original fork-point
git checkout -b myForkPoint # local branch
git merge cb4d1be           # merge in 1.34.6 code

But this results in many merge-conflicts to files that I didn't alter. (I'm guessing because I'm trying to merge in a ref that is not reachable to my HEAD).

Using merge-base and comparing commits manually between release branches and master (such as 63596f and b23117) it seems that OpenUI5's release branches are populated by cherry-picking commits from master. The release branches are not merged back into master one they are done being updated.

git merge-base --is-ancestor aa08b45 origin/master; echo $?; # prints 1
git merge-base --is-ancestor cb4d1be origin/master; echo $?; # prints 1

So, perhaps this branching model is not conducive to working off the public release branches?

Regardless, is there a clean way to "upgrade" my fork?


Solution

  • The answer here was to create our own merge-base by merging the two release branches together and having the later-release (1.34.6) side win all conflicts (using a merge-strategy).

    Then, merge that merge-base into our own forked branch.

    This way, the contents of each release branch are reachable from our fork-point, so all conflicts from the second merge will only be from the changes that we introduced.

    Here are the steps:

    # first create the merge-base
    git branch merge-1.34.6 1.34.6
    git checkout merge-1.34.6
    git merge rel-1.28 -s ours 1.34.6
    
    # next merge the merge-base branch into us
    git checkout myForkPoint
    git merge merge-1.34.6
    ...fix conflicts, stage and commit...