Skip to content

Merging between version branches

Guy Margalit edited this page Jan 3, 2018 · 11 revisions

Once we create a version branch, let's say 2.0, and keep pushing commits to that version branch, and in the meanwhile more commits are added to master.

This wiki describes how to forward merge changes from 2.0 to master.

What works?

# fetch all relevant branches
git fetch origin master:master
git fetch origin 2.0:2.0

# create new branch from master
git checkout -b guy-merge-from-2-0 master

# merge that branch from 2.0
git merge 2.0

# manually resolve conflicts for the entire merge ...

# rebase the merged commits on top of master
# this will remove unneeded commits and potentially also the merge commit
git rebase master

# push and PR
git push

What doesn't work?

We tried to do it using a standard rebase as follows:

# fetch all relevant branches
git fetch origin master:master
git fetch origin 2.0:2.0

# create new branch from 2.0
git checkout -b guy-merge-from-2-0 2.0

# rebase that branch from master
git rebase master

# manually resolve conflicts per commit ...

# push and PR
git push

This method seems to work well for the first time, and all the commits from 2.0 are re-created on master, so they have different commit hashes.

However, when there are resolved conflicts and this method is repeated the problem is that git does not identify those commits on master as resolved conflicts, and the next rebase will ask to manually resolve the same conflict again without any real diff to apply.

Clone this wiki locally