{"id":56779,"date":"2019-06-06T10:02:26","date_gmt":"2019-06-06T18:02:26","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/devops\/?p=56779"},"modified":"2019-06-06T13:35:20","modified_gmt":"2019-06-06T21:35:20","slug":"improving-azure-devops-cherry-picking","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/improving-azure-devops-cherry-picking\/","title":{"rendered":"Improving Azure DevOps cherry-picking"},"content":{"rendered":"<p>One of the more powerful git commands is the <a href=\"https:\/\/git-scm.com\/docs\/git-cherry-pick\">cherry-pick<\/a> command. This command takes one or more existing commits and applies each commit\u2019s changes as a new commit on a different branch. This can be an extremely powerful component of many git workflows such as the Azure DevOps team&#8217;s <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/learn\/devops-at-microsoft\/release-flow#releasing-hotfixes\">Release Flow<\/a>. To highlight a common use-case for it, let\u2019s talk about hot-fixing release branches.<\/p>\n<p>In this scenario, we have a master branch that devs contribute to. When a release is ready, a release branch is created based off the latest commit in master and a deployment goes out to end users. After people begin using this newly released version, your team starts to get flooded with new bug reports\u2014now it\u2019s time for a hotfix!<\/p>\n<p>As the dev tasked with fixing the bug, you create a hotfix branch (based off the head of the release branch) and commit the necessary changes (commits A and B in Figure 1) to that branch. After you\u2019re satisfied that you have addressed the issue, you then open a pull request (PR) back into the release branch. The next step is to ensure that the next release doesn\u2019t contain the bug\u2014this is exactly when cherry-picking can help. So, you cherry-pick the hotfix commit(s) to a branch based off the head of master and open a PR into master.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2019\/06\/cherry-pick-workflow.png\" alt=\"Cherry-pick release workflow\" \/><\/p>\n<p><em>Figure 1. Cherry-pick release workflow<\/em><\/p>\n<h2>Current Azure Repos cherry-pick support<\/h2>\n<p>This workflow is so common that <a href=\"https:\/\/azure.com\/devops\">Azure DevOps<\/a> has a built-in <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/repos\/git\/pull-requests?view=azure-devops\">capability<\/a> to cherry-pick a PR\u2019s commits to a new topic branch directly from a browser. However, this can be cumbersome if you need to apply commits to multiple branches at once while also opening new PRs.<\/p>\n<p>For example, inside Microsoft, it is very common for product teams to cherry-pick changes into multiple branches at the same time. For example, the Office team has multiple versions at various stages of deployment at any given time, meaning there are multiple release branches to hotfix.<\/p>\n<p>With the current mechanism, you would have to cherry-pick to each new topic branch and then open a PR from the topic branch into the target branch \u2014 for every branch that needed the hotfix. Therefore, we built this extension to help Microsoft product teams, such as Office, and we wanted to share it with everyone!<\/p>\n<h2>Multi-cherry-pick extension<\/h2>\n<p>In order to provide an easy way to cherry-pick a PR\u2019s commits to multiple branches at once, we added a new context menu item that sits right below the current cherry-pick menu item.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2019\/06\/cherry-pick-context-menu.png\" alt=\"Multi cherry-pick extension context menu button\" \/><\/p>\n<p><em>Figure 2. Multi cherry-pick extension context menu button<\/em><\/p>\n<p>For each branch selected, a new topic branch will be created with the applied changes. If the <strong>Pull request<\/strong> option is selected, a pull request will be opened to the target branch.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2019\/06\/cherry-pick-form.png\" alt=\"Multi cherry-pick extension user interface\" \/><\/p>\n<p><em>Figure 3. Multi cherry-pick extension user interface<\/em><\/p>\n<h2>Getting started<\/h2>\n<ol>\n<li>Install the extension from the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=1ESLighthouseEng.pr-multi-cherry-pick\">marketplace<\/a> into your Azure DevOps organization.<\/li>\n<li>Navigate to your pull request.<\/li>\n<li>Select the context menu (&#8230;)<\/li>\n<li>Select Multi-cherry-pick.<\/li>\n<li>Add as many cherry-pick targets as you would like.<\/li>\n<li>After you click Complete, a summary page will appear with links to branches and PRs created from the tool.<\/li>\n<\/ol>\n<p>This makes it much simpler to support workflows where multiple (or even just one) destinations need to have commits applied.<\/p>\n<p><strong>Note<\/strong>: because this extension is <a href=\"https:\/\/github.com\/microsoft\/azure-repos-pr-multi-cherry-pick\">open source<\/a>, you can file feature requests, suggestions, and issues at <a href=\"https:\/\/github.com\/microsoft\/azure-repos-pr-multi-cherry-pick\/issues\">GitHub<\/a>.<\/p>\n<p>Lastly, please leave us a review in the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=1ESLighthouseEng.pr-multi-cherry-pick\">marketplace<\/a>; we\u2019d absolutely love to hear your feedback.<\/p>\n<p>Happy cherry-picking!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the more powerful git commands is the cherry-pick command. This can be an extremely powerful component of many git workflows such as the Azure DevOps team&#8217;s Release Flow. To highlight a common use-case for it, let\u2019s talk about hot-fixing release branches.<\/p>\n","protected":false},"author":4798,"featured_media":56788,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229,225],"tags":[],"class_list":["post-56779","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-community","category-git"],"acf":[],"blog_post_summary":"<p>One of the more powerful git commands is the cherry-pick command. This can be an extremely powerful component of many git workflows such as the Azure DevOps team&#8217;s Release Flow. To highlight a common use-case for it, let\u2019s talk about hot-fixing release branches.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/56779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/4798"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=56779"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/56779\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/56788"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=56779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=56779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=56779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}