Reputation: 763
Context:
I have created a branch (let's call it new-feature
), based off master
. I plan to create a pull request that will remain open over the next few months.
During this time, I will be doing feature development by branching off of new-feature
. Once a branch has been reviewed and approved, I will create a pull request to merge that bit of work into new-feature
When all is said and done, new-feature
will be merged into master
.
My question:
Let's say one of my new-feature
child branches (let's call it child-branch-1
) contains a change that also needs to be merged into master
BEFORE new-feature
is merged into master
?
Am I able to use a single branch for this change, creating 2 separate pull requests (1 PR to merge the change into master
, and another PR to merge the change into new-feature
, respectively), or is it better to use 2 different branches (1 based off of master
, and 1 based off of new-feature
, with a PR for each) to accomplish this?
Upvotes: 1
Views: 134
Reputation: 1329322
Let's say one of my new-feature child branches (let's call it
child-branch-1
) contains a change that also needs to be merged intomaster
BEFOREnew-feature
is merged intomaster
?
That branch child-branch-1
includes the history (in part) of new-feature
.
You cannot merge child-branch-1
as-is to master, because it includes too much.
upstream/master
(with upstream being the remote of the original repository you have forked)git cherry-pick
one or several commits from child-branch-1
to that new branchUpvotes: 2
Reputation: 63
I would firstly merge child-branch-1
to master. Once I did that, I would then make a pull from master
to new-feature
that way you'd have the change you need in new-feature
and the children of such branch would have the change too.
Since you need to have child-branch-1
in master before you put it in new-feature
, I think it's better to get child-branch-1
from master instead of taking it from new-feature
.
I'm speaking about this thinking of it as a simple general case, your personal case may be more complicated though. It may be possible that you need some things from child-branch-1
to go to master, and some other things to go to new-feature
. If that's case, I would use another approach, maybe you can tell us a few more details about your issue.
Upvotes: 0