共用方式為


Copy changes with cherry-pick

TFS 2017 | TFS 2015 | TFS 2013

Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015

Copy commits from one branch to another using cherry-pick. Unlike a merge or rebase, cherry-pick only brings the changes from the commits you select, instead of all the changes in a branch.

Cherry-pick is a great way to tackle these common problems:

  • Accidentally committing on the wrong branch. Cherry-pick the change(s) over to the correct branch and then reset the original branch to the previous commit.
  • Pulling out a set of commits made in a feature branch so you merge them back to your main branch sooner.
  • Porting in specific commits from the main branch without rebasing your branch.

In this tutorial you learn how to:

  • Cherry-pick a commit

Cherry-pick a commit

  1. In a completed PR in your Azure DevOps project, select Cherry-pick. In an active PR, select Cherry-pick from the ... menu. This action creates a new branch with the copied changes.

  2. In the Cherry-pick pull request pane:

    1. Under Target branch, select the branch where you want to copy the PR changes.
    2. Under Topic branch name required, change the cherry-pick PR branch name if you want.
    3. Choose whether to Cherry-pick as a single commit.
    4. Select Cherry-pick.
  3. On the New pull request screen, select Create.

  4. Merge the new PR to complete the cherry-pick.

Next steps