0

I have commit A, commit B and C that got merged into branch A. C obviously has A and B as well. I have a local fork of branch A that I've been pushing changes to.

I also have a fork of branch B (release branch). I need to push changes from branch A/branchA_fork into branch B. What's the best way to do this? Everyone in my team suggests I cherry pick manually. Sounds very error prone. Would love some tips on a clean way to do this.

rickygrimes
  • 2,637
  • 9
  • 46
  • 69

1 Answers1

0

Considering you can cherry-pick a range of commits, you could git cherry-pick A..C in one go.

That is the equivalent of:

        af--af--af (branchA_fork)
       /
a--a--A            (branchA)

b--b--b            (branchB)
git switch branch A/branchA_fork 
git rebase --onto branchB $(git merge-base branchA branchA_fork) branchA_fork

That would replay any commit after the branchA_fork origin commit from branchA (commit A), up to branchA_fork head onto branchB.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250