Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stack a second pull request on top of an existing one before either are accepted?

Tags:

git

github

I want to present the repo owner with two distinct pull requests, the second based upon the first.

I have an existing pull request pending on a repo (that I do not own).

I want to base a further change on my existing pull request.

master -> A -> B

I made my the changes in B on a new branch in my fork based on the branch I used for A.

git branch -b B A

I have pushed upstream with:

git push --set-upstream origin B

When I try to create a pull request for B through the github UI it gives me the changes in A + the changes in B in a single pull request.

If I try this from the commandline:

hub pull-request -b A

It doesn't work because A is not a branch in the upstream repo, only in my fork.

What should I be doing differently in order to present the repo owner with two pull requests, one stacked upon the other?

like image 865
Thomas David Baker Avatar asked Sep 23 '16 14:09

Thomas David Baker


People also ask

Can I raise 2 Pull Requests from same branch?

There can be only one open PR from a given branch.

How do I combine Pull Requests?

Under your repository name, click Pull requests. In the "Pull Requests" list, click the pull request you would like to add to a merge queue. Click Merge when ready to add the pull request to the merge queue.


1 Answers

It's ok to stack a ton of changes in a single pull request, ettiquette-wise?

If your second change absolutely depend on the first one, then... yes.

That being said, you should resolve PR A first, meaning the maintainer of the original repo should evaluate, accept and merge your first PR.

In the meantime, you can make a new branch for B, based on A, and push that branch to your fork, but you should not make a new PR before the first is resolved.
Especially if the first PR is rejected.

In the OP's case:

I ended up treating all my stacked changes as one pull request and if they want to review sensibly they could click into each commit one by one

That makes sense when all those changes can be reviewed as one big new evolution.
The best practice recommends small incremental changes but in this instance, adding commit to an existing PR (since, indeed, there is no way to "stack PR") is the way to move forward with the development process.

like image 195
VonC Avatar answered Oct 27 '22 10:10

VonC