gitazure-devops

How to cherry pick one commit from dev to main?


In a repository, there's a dev branch and a main branch. There's been a few commits in the dev branch and I want to take a specific commit to the main branch. I'm using Azure DevOps/GitHub Desktop and everything I've tried, it appears to take all the commits and not just the specific commit. I can't push directly to main; I need to use a pull request. How can I merge a single commit?

I've tried to cherry pick the commit from dev to a new branch and then create a pull request from the new branch to main but that appears to pick all commits from the dev branch.


Solution

  • I need to use a pull request. How can I merge a single commit?

    Based on your requirement, you can try the following steps to do the cherry pick in Azure DevOps:

    Step1: Create a new branch based on main.

    enter image description here

    Step2: Navigate to Repos -> Commits -> Select the target One commit. Then you can use the Cherry Pick option to create a new branch based on the new branch in Step1.

    For example:

    enter image description here

    Then you can select the branch.

    enter image description here

    Step3: It will automatically create a Pull Request and contain only one commit.

    For example: From cherry pick branch to main branch

    ![enter image description here