Reputation: 1353
Let's say I have a fork of a repo, and my repo has three branches:
branch_1
is off of upstream/master
, but branch_1_a
is off of branch_1
(ie, it was created via git checkout -b branch_1_a branch_1
)
How do pull requests work in this scenario if say I want to create a pull request for the changes in branch_1
and also a pull request for the changes in branch_1_a
. Do I first have to create a PR to merge branch_1_a
into branch_1
? Or do I create PR for branch_1
, have that merged into upstream/master
, and then create a PR for branch_1_a
? Or can I have a PR for each simultaneously to go into master (though I can't wrap in my mind how this would work)?
Upvotes: 5
Views: 2510
Reputation: 31274
first of all, git
doesn't know any "pull requests" (this is a concept of services such as gitlab, github, bitbucket,...).
instead git
knows merges.
a pull request is just a way to tell someone in charge that you want to git merge
a branch with another.
second, a branch is really just a label you give to a set of patches.
now, to answer your question: yes it is totally possible to merge branches and subbranches.
in the simplest case, branch_1_a
contains the entirety of branch_1
(that is: all commits that are in branch_1
are also in branch_1_a
).
if you first merge branch_1_a
, then merging branch_1
will become a no-op (since your master
now already contains branch_1
).
if you first merge branch_1
, then merging branch_1_a
will simply add the additional patches that make branch_1
different from branch_1_a
.
Upvotes: 3
Reputation: 66
Assuming the fork you're referring to exists on some hosted git service such as github or bitbucket, you should be able to perform the merge of branch_1_a
into branch_1
in your local clone of the fork and then push branch_1
to the remote fork repo after which you can open a PR for branch_1
against the repo you originally forked from.
Upvotes: 0