Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to divide one pull request into two different pull request on github

Tags:

git

github

How can I divide one pull request into two pull requests? I committed ten times in one pull request, and I want to divide them into two different pull requests because the first six commits are unrelated to the last four commits. I use Ubuntu os with git. As I am new to git, I am wondering how to input git commands step by step to do that. Any advice would be be highly appreciated.

like image 648
Logan Guo Avatar asked Sep 30 '14 02:09

Logan Guo


People also ask

Can we create 2 Pull Requests from same branch?

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

How do I split my PR into two PRs?

To stack two PRs, checkout the first branch from your base master (or develop ) and push your changes. Create the PR with the base as master . Then, checkout the second branch from the first.

Can a pull request have multiple branches?

The short answer is "no" but depending on how the branches are related there may be a way to work things so you're guaranteed not to have conflicts after the first merge.


1 Answers

You basically have a duplicate of Splitting a Branch in 2 The graphs there are good so not bothering to duplicate them.

First create a second branch pointing at your sixth commit

git branch branch2 HEAD~4

or

git branch branch2 COMMIT_6_SHA

branch2 is now done and ready to create a pull request for the first 6 commits.

Now you want to use git rebase --onto to move your existing branch with the other 4 commits so they are hanging off your upstream

git rebase --onto @{u} branch2

And that's it.

like image 184
Andrew C Avatar answered Nov 16 '22 04:11

Andrew C