Search code examples
gitrestazure-devopstfs-sdk

Create pull request from specific commit via VS team services


I am trying to create a pull request from specific commit. Is it possible?

Detail:

There is commit c1, c2, c3 in branch b1, and commit c3 is also in branch b2. Create a pull request to merge commit c2 into branch b2.

My failed attempts:

  • Create a new branch from specific commit, couldn't find any VS team services API for this.
  • Create a tag on specific commit, don't know how to, only found get tag api.
  • Build a temporary branch b3 from b2, cherry-pick commit c2 to b3 and create pull request from b3 to b2. I don't see any way to pick a existing commit to a branch from official document.

Solution

  • Since the REST Api doesn't have any features to perform merges nor conflict resolution, anything that has to do with merges, rebases, cherry-picks etc needs to be performed locally before pushing the commit data back to VSTS.

    The simplest solution would be to perform a clone of the target repo and then to perform the changes before pushing them back.

    Depending on what you're trying to accomplish, a shallow clone may suffice, though if you want to cherry pick old commits, that may not work for you.