Andrew
Andrew

Reputation: 6860

Using features from two independent branches?

I have two independent branches off of master, A and B. I want to create a new branch C that uses code that I have created in A as well as in B. I can't just branch off one of A or B because they won't have all the features by themselves. What is is the canonical way to approach this problem? git cherrypick the files that I need?

Upvotes: 1

Views: 207

Answers (2)

user2031271
user2031271

Reputation:

A > git checkout -b C
C > git rebase B

Your new branch C will have commits from A rebased to new commits from B. Hence, containing commits from both the branches that are not master.

Upvotes: 0

Tonio
Tonio

Reputation: 1546

Create a branch from either and merge the other. For example:

$ git checkout -b C A
$ get merge B

(Which is what @crashmstr suggested in his comment.)

Upvotes: 1

Related Questions