How to modify a pull request on GitHub to change target branch to merge into?

后端 未结 5 999
孤街浪徒
孤街浪徒 2021-02-03 16:19

I have a pull request that is requesting a merge into master from my branch, but the owner wants me to change the request to merge into a different branch from my branch.

<
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-03 16:56

    Update August 2016: Change the base branch of a Pull Request finally allows for changing that branch.
    (And this closes issue 18, which was 3 years old and had 1500+ comments)

    After you’ve created a pull request, you can modify the base branch so that the changes in the pull request are compared against a different branch.


    Original answer:

    Since a PR cannot be edited in term of branch (see below), the easiest way would be to:

    • create a local new branch on top of your current branch
    • push that new branch
    • make a new PR with the right destination.
    • close the previous PR
    • reference the "old" pull request from the new one; eg. Supersedes #123 (as commented below by Rivera)

    (original answer, valid only when creating the PR)

    You could try and chose another base branch, as in "Changing the branch range and destination repository" (Clicking on the Edit button at the top of a PR page)

    https://github-images.s3.amazonaws.com/help/pull_requests/pull-request-review-edit-branch.png

    The easiest way of thinking about the branch range is this:

    • the base branch is where you think changes should be applied,
    • the head branch is what you would like to be applied.

    Changing the base repository changes who is notified of the pull request.
    Everyone that can push to the base repository will receive an email notification and see the new pull request in their dashboard the next time they sign in.

    If you select as a base branch the one that the original maintainer (the owner) wants, your PR should merge from your branch (unchanged) to the new base branch.

提交回复
热议问题