git checkout -b branchAB merge-base git merge branchA git merge branchB git rebase --onto merge-base merge-base branchAB