DEV Community

loading...

Multiple Github PRs?

Burdette Lamar
Started out teaching English at Embry-Riddle. Graded 10,000 essays. Lesson learned. Became a mathematics teacher. Discovered computing. Never looked back.
・1 min read

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 branch hash.
  • I have more changes, to a different file (say, array.c), in my branch array, 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 for hash.c.

So:

  • Is it possible to create a second PR for array.c, without including the changes for hash.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.

Discussion (5)

Collapse
rkichenama profile image
Richard Kichenama

Assuming you have develop as the main branch hash and array will merge into, you can git 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 the array branch

Collapse
burdettelamar profile image
Burdette Lamar Author

Great! Thanks much!
Then when one PR is merged, the other will still be capable of a clean merge?

Collapse
rkichenama profile image
Richard Kichenama

yes, under these conditions. It gets messier if the changes you want to separate are spread among different commits.

Collapse
thebouv profile image
Anthony Bouvier

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).

Collapse
dhulipallas profile image
Sandeep

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.