Search code examples
azure-devopsazure-devops-rest-apiazure-repos

Create a Pull Request based on a commit


Is it possible to create Pull Request based on a commit using Azure DevOps API? For example, consider this is my source branch with the following commit history:

commit #5
commit #4
commit #3
commit #2
commit #1

Can I create a Pull Request such that Pull Request should ONLY include the following commits:

commit #3
commit #2
commit #1

Solution

  • Rest Api (and manual creation) does not support commit selection... You may try to create a temporary branch and use PR from it.

    To create a branch, try to use refs: Update Refs

    The request body should look like this:

    [
      {
        "name": "refs/heads/my-temporary-branch",
        "oldObjectId": "0000000000000000000000000000000000000000",
        "newObjectId": "commit #3 ID"
      }
    ]