Search code examples
githubpull-request

Programmatically change base branch for a github pull request


Title says it all…

Anyone have any code to update the base branch for a github pull request programmatically? Don't really care about the language.


Solution

  • The API method to change the base branch of a PR (Pull Request) is described here:

    GitHub recently (August 2016, less than 2 years ago at the time of writing this) added the ability to change the base branch on a Pull Request after it's created.
    Now we're updating the Pull Request API to enable the new functionality.

    For example:

    curl "https://api.github.com/repos/github/hubot/pulls/123" \
      -H 'Authorization: token TOKEN' \
      -d '{ "base": "master" }'
    

    The Pull Request base will be updated to point to the master branch.

    You can embed that curl call in any script language you want.