Siri
Siri

Reputation: 129

Merge 2 branches into new one locally

I know basic merging. To merge A into B: git checkout B, git merge A. But how can I merge into a new branch?

I want a totally new branch where I can work with the result of both A and B.

In other words, I want my branch B as the base in the new branch C and get merged by A.

So, the result would be C = B + A. Not C = A + B.

How can I achieve that?

Upvotes: 1

Views: 1658

Answers (1)

zaakm
zaakm

Reputation: 151

You can do following

  1. git checkout -b "C" (while being in branch B, then you will have everything from B into C)
  2. git merge "A" (while being in branch C, then you have merged all changes from A into new branch C)

Upvotes: 2

Related Questions