How to open multiple pull requests on GitHub

本秂侑毒 提交于 2019-12-17 17:29:07

问题


When I open a pull request on GitHub.
All commits since my last request and all new ones are automatically added to this request.

I can't seem to control which commits are added and which are not.
When I try to open another pull request, I get an "Oops! There's already a pull request" error.

Is there any easy way to open multiple pull requests without having to mess around with the command line?


回答1:


Pull requests are based on a branch.
The only way to open up a pull request for multiple commits is:

  1. Isolate them into their own branch.
  2. Open the pull requests from there.



回答2:


The easiest way I've found to do this is with the hub command (https://github.com/defunkt/hub).

From your topic branch ("feature" in this example) that you want to create a pull request for, you can just run:

git pull-request

(remember to push your branch first!)

And it will open a new pull request on GitHub for "YOUR_USER:feature".

If you've already created an issue on GitHub, you can even attach a pull request to that existing issue (something you can't do from the web UI):

$ git pull-request -i 123
[ attached pull request to issue #123 ]



回答3:


You actually CAN do this without creating another branch, but it takes a bit of playing around.
Here's the steps:

  1. Identify the two commit ranges you want to pull. Here's what i'll use for an example:
    (other/master) A -> B -> C -> D -> E (yours/master)
    Let's say that you want to pull B and C in one request, and D & E in another.
  2. Make a pull request. Have the left side ("Base") be commit A. For the right side ("head"), type in the commit number of C.
  3. Write the description for your first request.
  4. Make another request. For the base, type in the commit number of C, and for the head, put E (yours/master).
  5. Write the description.

As I see it, the pull request sees commit C as a branch point. Or something.



来源:https://stackoverflow.com/questions/8450036/how-to-open-multiple-pull-requests-on-github

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!