Checking mergeability of pull requests

Warning! Please do not depend on using Git directly or GET /repos/:owner/:repo/git/refs/:ref for updates to merge Git refs, because this content becomes outdated without warning.

A consuming API needs to explicitly request a pull request to create a test merge commit. A test merge commit is created when you view the pull request in the UI and the "Merge" button is displayed, or when you get, create, or edit a pull request using the REST API. Without this request, the merge Git refs will fall out of date until the next time someone views the pull request.

If you are currently using polling methods that produce outdated merge Git refs, then GitHub recommends using the following steps to get the latest changes from the base branch (usually master):

  1. Receive the pull request webhook.
  2. Call GET /repos/:owner/:repo/pulls/:pull_number to start background job for creating the merge commit candidate.
  3. Poll your repository using GET /repos/:owner/:repo/pulls/:pull_number to see if the mergeable attribute is true or false. You can use Git directly or GET /repos/:owner/:repo/git/refs/:ref for updates to merge Git refs only after performing the previous steps.