Redaguoti

Bendrinti naudojant


Copy changes with cherry-pick

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

Visual Studio 2019 | Visual Studio 2022

Git cherry-pick copies the changes from one or more source branch commits to a target branch. Unlike merge or rebase, cherry-pick lets you select specific source branch commits. For each source branch commit that you cherry-pick, Git creates a corresponding commit on the target branch.

You can cherry-pick to tackle these common tasks:

  • Deploy a specific feature from one branch to another.
  • Copy work that you committed on the wrong branch.
  • Apply a bug fix on multiple branches.

For an overview of the Git workflow, see Azure Repos Git tutorial.

Prerequisites

Category Requirements
Project access Member of a project.
Permissions - View code in private projects: At least Basic access.
- Clone or contribute to code in private projects: Member of the Contributors security group or corresponding permissions in the project.
- Set branch or repository permissions: Manage permissions permissions for the branch or repository.
- Change default branch: Edit policies permissions for the repository.
- Import a repository: Member of the Project Administrators security group or Git project-level Create repository permission set to Allow. For more information, see Set Git repository permissions.
Services Repos enabled.
Tools Optional. Use az repos commands: Azure DevOps CLI.

Note

In public projects, users with Stakeholder access have full access to Azure Repos, including viewing, cloning, and contributing to code.

Category Requirements
Project access Member of a project.
Permissions - View code: At least Basic access.
- Clone or contribute to code: Member of the Contributors security group or corresponding permissions in the project.
Services Repos enabled.

Cherry-pick a commit

Azure Repos

Azure Repos provides limited support for cherry-picking, and only for the purpose of creating a pull request to apply a hotfix on a target branch. For more information, see Improving Azure DevOps cherry-picking.

The Cherry-pick option in the pull request menu in Azure Repos does the following:

  1. Creates a new topic branch from the pull request's target branch.
  2. Cherry-picks all changes from the pull request's source branch to the new topic branch.
  3. Prompts you to create a new pull request to merge the new topic branch into another target branch.

For a step-by-step tutorial, see Create a new pull request with cherry-pick.

GitHub

The GitHub web interface doesn't support cherry-picking, but GitHub Desktop does. For step-by-step guidance on how to cherry-pick in GitHub Desktop, see Cherry-picking a commit.

Next steps