Merge pull request to a different branch than default, in Github

A pull request comes into my repo hosted on Github. By default it is merged into the master branch.

Is there any way for me to change which branch the changes would be merged into?


Solution 1:

As of 15.08.2016 GitHub allows changing the target branch of a pull request via the GUI. Click Edit next to the title, then select the branch from the dropdown.

screenshot

You can now change the base branch of an open pull request. 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. By changing the base branch of your original pull request rather than opening a new one with the correct base branch, you’ll be able to keep valuable work and discussion.

Solution 2:

The submitter can change that when they issue the pull request, but once they issue it you can't change it.

On the other hand, you can manually merge their branch and push, which I semi-regularly do for mistargetted pull requests.

You may find the hub gem helpful in working with the components of the pull request.

That gem wraps up the manual process, which is:

  1. Add a remote for the fork to your local checkout.
  2. Fetch that remote.
  3. git checkout ${target_branch} && git merge ${remote}/${branch}
  4. git push origin ...