Reputation: 45
I have an old branch ready for deployment: Branch A and a patch branch: Patch A created off Branch A
Changes have been made on new branches from master: Branch B, C & D
For the deployment I want all those changes from the new branches into my Patch A branch but each of the new branches: Branch B, C & D have multiple commits
Here is a map to better illustrate
-- Master
----Branch B
----Branch C
----Branch D
----whole host of other branches
then further down
----Branch A - deployment branch
------Patch A - patch which has Branch A at head and needs Branch B, C & D code
I have seen git merge, rebase and cherry-pick but unsure which to use to achieve this
Upvotes: 1
Views: 142
Reputation: 2477
Assuming there are no textual conflicts between changes on branches B,C,D and you aren't too picky about the shape of the resulting git history, the simplest approach is probably to merge each of the branches B, C, D (one at a time) into your Patch A branch, with commands like:
git checkout patch-A
git merge B
git merge C
git merge D
If you hit conflicts then you'll need to resolve them at each step.
This will result in multiple merge commits in the patch-A branch git history, but if all you care about is the textual content it's a quick-and-dirty approach.
If you want to avoid those and instead get a linear git history, you could rebase each branch B,C,D onto your working branch and then use a fast-forward merge, something like this:
git checkout B
git rebase patch-A
git checkout patch-A
git merge --ff-only B
git checkout C
git rebase patch-A
git checkout patch-A
git merge --ff-only C
git checkout D
git rebase patch-A
git checkout patch-A
git merge --ff-only D
Again if there are conflicts you'll need to resolve them (during the rebase steps).
Upvotes: 1