Bobcares

Cherry Pick Azure DevOps | The Complete Guide

by | May 2, 2024

What is Cherry Picking In Azure DevOps?

Azure DevOps Cherry Pick is a process of the software or application development that includes the crafting of extensive amounts of code. In order to add functionality or to introduce new elements, DevOps specialists create various iterations of the product across multiple release branches.

Meanwhile, solving the problems with fixing bugs or errors can mean changes on multiple release branches, which can be a very difficult and time-consuming task. Nevertheless, techniques such as DevOps cherry picking simplify developers’ work.

cherry pick azure devops

In order to understand the concept, let us go back to the basics of software configuration management. During the application development process, DevOps specialists make different versions that can be used for modifications and improvements. Each branch corresponds to a version that is used for the development of the software.

 

The tree analogy is the most fitting one since each of the branches is grown from a source branch and is linked to other sub-branches. Consequently, multiple branches of the software are developed that can be changed or modified according to the application’s requirements. When applying the changes, a DevOps professional will create a new fix branch, make the necessary changes, and then, produce a copy of these modifications to other branches.

Cherry picking is exactly the method that is used for the propagation of the required corrections. In this way, developers use this technique to pick out the corrections they need and then move them to the target branch.

Cherry Picking Process In Azure DevOps

To explain, we must follow the software development process accurately by cherry-picking the right programs through the use of its corrections:

  1. Toward the finish of the initial stage of the software, DevOps professionals form a primary release branch.
  2. Moreover, the software developers, if they discover flaws or get suggestions from users, develop a new branch to solve the issue adding the necessary changes. 
  3. Later on cherry-picking applied to select these fixes and implement them into the release branch.

This method helps in the complete removal of bugs in different versions of the software.

cherry pick azure devops

The picking is done on the main branch to avoid the deployment of a new version with the same bug.

Cherry picking, fusion, rebase: what are the differences?

Cherry picking differentiates itself from such other bug correction methods as:

  • Merge: This way, all changes are combined to form a new version of the software.
  • Rebase: In this case, the changes are put in the goal branch without touching the source branch.

In comparison to these two methods, cherry picking offers the advantage of applying specific changes.

Several companies adopt the cherry-pick version of Git in place of the other two methods of rebase and merge. By using cherry-pick, we can copy the selected commits from one branch to another. The rebase or merge way of working allows a developer to import only the adjustments that are made in each commit chosen, not all the changes in a branch.

Why Use Git Cherry-pick

While cherry-pick offers an effective solution to several common problems: 

  1. Rectifying accidental commits on the wrong branch. By applying changes to the appropriate branch and simultaneously reverting the original branch back to its previous state, Cherry-pick can be used as a remedy in cases where commits are mistakenly made on the wrong branch.
  2. Extracting a series of commits from a feature branch for earlier integration into the master branch.
  3. Incorporating specific commits from the master branch into your own branch without needing to rebase your branch. It is a beneficial technique for hotfixes integration without merging the entire branch.
  4. Transferring common changes across incompatible branches within the source repository. These common changes can be applied to multiple branches in a sequence using commit IDs.

Copy changes with cherry-pick

GIT cherry-pick is a function that works by copying any changes from one or more commits of a source branch to a destination branch. Unlike merge or rebase, cherry-pick only requires you to individually select individual commits from the source branch. For each commit that was cherry-picked, Git will create a corresponding commit on the target branch.

One of the tasks that Cherry-pick can be used for are:

  • Deploying a specific feature from one branch to another.
  • Transferring work mistakenly committed on the wrong branch. 
  • A bug fix across multiple branches can be achieved by re-applying a bug fix across multiple branches.

How to Perform Cherry Picking using Azure DevOps

Azure DevOps comes with an incorporation tool that allows a person to select such changes (pull requests) from their browser and apply them to a new branch. 

 

This stands a step ahead of the classic way of cherry-picking in Azure DevOps, where users have to use a method that is integrated into the pull request to the web-based user interface to define a list of changes that should be used to build the cherry pick. The algorithmic solution of many variants and imprints of the approach were discovered in the methodical treatment of the set.

 

Primarily, this instrument makes the process of patching a single branch simple. Nevertheless, an error occurs when trying to apply patches to multiple branches, the way will be repeated for each of them. So, the good news is that the Azure DevOps multi-cherry picking extension takes charge of this task.

Other Useful Tools for Cherry Picking

Help besides the offered Azure DevOps may also be obtained from the use of DevOps tools to copy the branch commits to another branch. The tools which are also included in this category are:

  • Visual Studio 2022
  • Visual Studio 2019
  • Visual Studio 2017
  • Git command line

These tools offer multiple options for cherry picking changes, enhancing the efficiency of the process.

Why use Cherry Picking with Azure?

In the pursuit of delivering an exceptional product to end-users, DevOps frequently generates multiple versions, facilitating continuous enhancements while preserving the core structure. However, to ensure effective propagation of these modifications across versions, it’s essential to leverage cherry picking with Azure DevOps.

This practice empowers developers to:

  • Deploy specific functionalities from one branch to another.
  • Transfer well-executed work from an incorrect branch to a designated target branch.
  • Streamline collaboration among teams for software configuration.
  • Rectify issues across multiple branches.

How does Cherry Pick work in Azure DevOps?

While the process isn’t exclusive to Azure DevOps and is a fundamental aspect of Git, there are multiple approaches available:

1. Cherry picking:
  • Cherry-picking involves selecting specific commits from one branch and applying them to another branch. This method can be effective for incorporating changes from feature branches into other branches, such as a release branch or master.
  • However, complications may arise if changes to the same files are made by multiple branches or if conflicts occur between the changes being cherry-picked and the target branch.

2. Creating a new branch for merging into release:
  • This approach involves creating a new branch from the ‘develop’ branch just before the merges of feature branches F1, F2, and F3.
  • After creating the new branch, you merge only the changes from feature branches F1 and F3 into this branch, ensuring that you avoid introducing the problematic changes from F2.
  • Once the new branch is ready, it can be merged into the master branch, effectively incorporating the desired changes without the issues introduced by F2.
3. Reverting F2 changes in development:
  • In this method, you revert or undo the changes introduced by feature branch F2 on the ‘develop’ branch.
  • Reverting the changes from F2 eliminates the problematic alterations, restoring the ‘develop’ branch to its state before the introduction of those changes.
  • After reverting the changes, you can merge the ‘develop’ branch into the master branch, ensuring that you don’t include the undesirable alterations from F2 in the final release.
4. Interactive rebase of development:
  • An interactive rebase allows developers to rewrite the commit history of a branch interactively.
  • By selectively removing the problematic commits, developers can ensure that the changes introduced by F2 do not affect the master branch.
  • Once you complete the rebase, you can merge the ‘develop’ branch into the master branch, incorporating only the desired changes.

Expanding on these points provides a clearer understanding of the various strategies available for addressing issues related to cherry-picking in Azure DevOps. Each approach has its advantages and considerations, depending on the specific requirements of the project and the nature of the changes involved.

Current Support for Cherry Picking in Azure Repos

The functionality of cherry-picking commits from a pull request (PR) to a new topic branch directly from a browser is widely utilized, prompting Azure DevOps to integrate a built-in feature for this purpose. However, the efficiency of this approach diminishes when there is a requirement to apply commits to multiple branches concurrently while also initiating new pull requests.

cherry pick azure devops

For example, within the Microsoft ecosystem, it’s commonplace for product teams to simultaneously incorporate changes into multiple branches. Consider the Office team, which manages several versions of their software at different deployment stages, necessitating the application of hotfixes across numerous release branches.

Under the current system, the process of cherry-picking commits means applying each commit individually to respective topic branches, followed by the initiation of a pull request from each topic branch to the target branch. This iterative process becomes laborious, especially when dealing with multiple branches requiring the same hotfix.

An advanced suppoort team such as Bobcares can adress this issues, so the choosing the right team for the job is necessary.

[Want to learn more about cherry pick Azure DevOps? Click here to reach us.]

Conclusion

In conclusion, whether you are the team of developers whose project is based on a Kubernetes platform or not, using cherry-picking as one of the answers to the problems of version management is really not a convenience but, rather, a necessity. It has been seen that the feature provides the option to pick only specific commits from one branch and apply them in another, which means a faster and closer relationship between the client, the system, and the users.

The teams utilizing Azure DevOps software have built-in functionality for the cherry-pick process and, therefore, the speed of collaboration, traceability during development, etc. is raised at a higher level, making the implementation of these features less time-consuming. The cherry-pick functionality permits faster deployment of fixes in the production, release, or other branches along with smooth cross-team interactions. In this way, the feature gives developers the ability to build and harden their codebase in less time.

Alongside that, with the cooperation of Bobcares, you will have the possibility to delve into the full capabilities of Azure DevOps such as cherry-picking, which handles multithreading issues and provides developers with necessary equipment to conduct their tasks more efficiently. Apart from the Multi-Cherry-Pick Extension, which is one, can be added. This chore task of cherry-picking will become even easier if the users can apply PR commits to multiple branches at once. Also, there will be new features available. These are only a few of the many features that Visual Studio has for its users.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.