Suppose (C'mon, just suppose):
- I'm working on some changes for a project on Github (say, the Ruby project).
- I have an open PR for a single file (say,
hash.c
) in my branchhash
. - I have more changes, to a different file (say,
array.c
), in my brancharray
, and I'd like to put up a second PR for those changes. - When I offer to create a second PR for
array.c
, its changes include those forhash.c
.
So:
- Is it possible to create a second PR for
array.c
, without including the changes forhash.c
? - If so, would a subsequent merge of either PR "foul" the other, so that it couldn't be sensibly merged?
Thanks for any help.
Top comments (5)
Assuming you have
develop
as the main branchhash
andarray
will merge into, you cangit checkout -b array develop
which will make a a branch based on develop where you can cherry-pick your commit with the array.c changes onto, then make the PR for thearray
branchGreat! Thanks much!
Then when one PR is merged, the other will still be capable of a clean merge?
yes, under these conditions. It gets messier if the changes you want to separate are spread among different commits.
It sounds like you may have created the hash branch, then created the array branch while still on the hash branch.
You should do this:
git checkout master
git pull
git checkout -b hash
make code changes for hash and commit them to hash branch
git checkout master
git checkout -b array
make code changes for array and commit them to array branch
Do you see what I mean?
You likely did this:
git checkout master
git pull
git checkout -b hash
make changes for hash
git checkout -b array (here is the mistake, this is branching OFF of hash branch, not master)
make changes for array
If you're using GitHub Flow which is all about feature branches being made off of master.
So, remember two things with this:
Always branch from master, and always make sure you have the most recent master (git pull it before branching off of it).
Usually when a PR is open on a branch you trying to merge, all the subsequent commits on the push branch will be available in opened PR. Basically in the PR it will show the diff of all the commits between your branch and the branch you trying to merge. So cut another branch which doesnt have your first file changes and do a pull request on it.