{"id":235744,"date":"2022-01-06T09:30:46","date_gmt":"2022-01-06T17:30:46","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=235744"},"modified":"2022-01-06T09:25:46","modified_gmt":"2022-01-06T17:25:46","slug":"introducing-new-git-features-to-visual-studio-2022","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/introducing-new-git-features-to-visual-studio-2022\/","title":{"rendered":"Introducing new Git features to Visual Studio 2022"},"content":{"rendered":"<p>We continue to enhance the Git experience in Visual Studio, and we are excited to announce some long-awaited updates in version 17.1 Preview 2. Download the latest Visual Studio Preview and check out the following new Git features.<\/p>\n<p style=\"text-align: center;\"><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/aka.ms\/vs2022preview\" target=\"_blank\">Download Visual Studio 2022 Preview<\/a><\/div><\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 115px;\">\n<tbody>\n<tr style=\"height: 23px;\">\n<td style=\"width: 28.7915%; height: 23px;\"><strong>New Git features<\/strong><\/td>\n<td style=\"width: 71.2085%; height: 23px;\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 28.7915%; height: 23px;\"><a href=\"#compare-branches\"><strong>Compare branches<\/strong><\/a><\/td>\n<td style=\"width: 71.2085%; height: 23px;\">Compare your checked out branch with any local or remote branch.<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 28.7915%; height: 23px;\"><a href=\"#checkout-commits\"><strong>Checkout commit<\/strong><\/a><\/td>\n<td style=\"width: 71.2085%; height: 23px;\">Checkout the tip commit or any previous commit of remote and local branches.<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 28.7915%; height: 23px;\"><a href=\"#multi-repo-branching\"><strong>Multi-repo branching<\/strong><\/a><\/td>\n<td style=\"width: 71.2085%; height: 23px;\">Manage and create new branches on all of your active repositories at the same time.<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 28.7915%; height: 23px;\"><a href=\"#line-staging-interactive-staging\"><strong>Line-staging (interactive staging)<\/strong><\/a><\/td>\n<td style=\"width: 71.2085%; height: 23px;\">Split your changes across different commits by staging sections of code changes.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><div class=\"alert alert-success\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Lightbulb\"><\/i><strong>Are you new to Git and source control?<\/strong><\/p>S<span class=\"x-hidden-focus\" data-contrast=\"auto\">tart utilizing Git and Visual Studio to their full potential by<\/span>\u00a0<a href=\"https:\/\/aka.ms\/GitNewBlog-EntryPoint\">signing up for the Git learning series<\/a>. <\/div><\/p>\n<p>&nbsp;<\/p>\n<h3>Compare branches<\/h3>\n<p>Comparing branches provides an overview of differences between two branches which can be very helpful before creating a pull request, merging, or even deleting a branch.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/compareBranches.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235750\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/compareBranches-300x275.png\" alt=\"Image compareBranches\" width=\"200\" height=\"183\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/compareBranches-300x275.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/compareBranches.png 492w\" sizes=\"(max-width: 200px) 100vw, 200px\" \/><\/a><\/p>\n<p>To compare your currently checked out branch with other branches using Visual Studio, you can utilize the branch picker hosted in the status bar and the Git changes tool window to choose any local or remote branch to compare with. Right click the branch you are targeting and select <strong>Compare with Current Branch<\/strong>. Alternatively, you can utilize the branch list on the Git Repository window to access the same command.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-Entry-Point.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235755 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-Entry-Point.png\" alt=\"Image Compare Branches Entry Point\" width=\"2500\" height=\"991\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-Entry-Point.png 2500w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-Entry-Point-300x119.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-Entry-Point-1024x406.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-Entry-Point-768x305.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-Entry-Point-1536x609.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-Entry-Point-2048x812.png 2048w\" sizes=\"(max-width: 2500px) 100vw, 2500px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/CompareBranches.gif\"><img decoding=\"async\" class=\"aligncenter wp-image-235972 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/CompareBranches.gif\" alt=\"Compare Branches\" width=\"1600\" height=\"876\" \/><\/a><\/p>\n<p>Selecting <strong>Compare with Current Branch<\/strong>\u00a0opens the compare branches experience where you can navigate the Changes list and select the file that you would like to compare.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-UI-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-235760\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-UI-1.png\" alt=\"Image Compare Branches UI\" width=\"2470\" height=\"794\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-UI-1.png 2470w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-UI-1-300x96.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-UI-1-1024x329.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-UI-1-768x247.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-UI-1-1536x494.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Compare-Branches-UI-1-2048x658.png 2048w\" sizes=\"(max-width: 2470px) 100vw, 2470px\" \/><\/a><\/p>\n<p><div class=\"alert alert-success\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Lightbulb\"><\/i><strong>Tip: use your preferred diff layout<\/strong><\/p>If you prefer an inline diff, you can use the diff configuration options gear and switch to an inline diff view.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Diff-configuration-options-1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235768 size-large\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Diff-configuration-options-1-1024x330.png\" alt=\"Image Diff configuration options\" width=\"640\" height=\"206\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Diff-configuration-options-1-1024x330.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Diff-configuration-options-1-300x97.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Diff-configuration-options-1-768x248.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Diff-configuration-options-1-1536x496.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Diff-configuration-options-1.png 1760w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><\/div><\/p>\n<p>&nbsp;<\/p>\n<h3>Checkout commits<\/h3>\n<p>Checking out a commit can be beneficial in multiple ways. For example, it allows you to go back to a previous point in your repository\u2019s history where you can run or test your code. It can also be helpful if you would like to review code from a remote branch (a colleague&#8217;s branch, for example). That way you don\u2019t need to create a local branch if you are not planning on contributing to it. In this case, you can just checkout the tip of the remote branch that you would like to review.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235771\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-296x300.png\" alt=\"Image Checkout Commit\" width=\"200\" height=\"203\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-296x300.png 296w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-24x24.png 24w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-48x48.png 48w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-96x96.png 96w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit.png 460w\" sizes=\"(max-width: 200px) 100vw, 200px\" \/><\/a><\/p>\n<p>To checkout a previous commit in Visual Studio, open the Git Repository window <strong>View &gt; Git Repository<\/strong>, right click on the commit you would like to go back to and select <strong>checkout (&#8211;detach).<\/strong><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-UI.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235773 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-UI.png\" alt=\"Image Checkout Commit UI\" width=\"2197\" height=\"1037\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-UI.png 2197w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-UI-300x142.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-UI-1024x483.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-UI-768x363.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-UI-1536x725.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkoutCommit-UI-2048x967.png 2048w\" sizes=\"(max-width: 2197px) 100vw, 2197px\" \/><\/a><\/p>\n<p>Visual Studio shows a confirmation dialog explaining that by checking out a commit you will be in a detached HEAD state. Meaning that the HEAD of your repository is going to point directly to a commit instead of a branch.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Confirmation.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235775 size-medium\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Confirmation-300x109.png\" alt=\"Image Checkout Confirmation\" width=\"300\" height=\"109\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Confirmation-300x109.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Confirmation-1024x371.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Confirmation-768x279.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Confirmation.png 1494w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Once you confirm your action by clicking <strong>Yes<\/strong>, Visual Studio shows a confirmation message and both the Git Repository, and the Git Changes windows show a Detached at a Commit state.<a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Success-Message-with-diagram.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235870 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Success-Message-with-diagram.png\" alt=\"Image checkout success message with diagram\" width=\"2141\" height=\"510\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Success-Message-with-diagram.png 2141w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Success-Message-with-diagram-300x71.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Success-Message-with-diagram-1024x244.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Success-Message-with-diagram-768x183.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Success-Message-with-diagram-1536x366.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Success-Message-with-diagram-2048x488.png 2048w\" sizes=\"(max-width: 2141px) 100vw, 2141px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/CheckoutCommit.gif\"><img decoding=\"async\" class=\"aligncenter wp-image-235976 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/CheckoutCommit.gif\" alt=\"Checkout Commit\" width=\"1600\" height=\"876\" \/><\/a><\/p>\n<p>Now that you are in a detached head state, feel free to run and test your code or even explore and commit changes. When you are done exploring and want to go back to your branch, you can choose to discard your changes by checking out an existing branch or choose to keep your changes by <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/version-control\/git-create-branch\">creating a new branch<\/a> first.<\/p>\n<p><div class=\"alert alert-info\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Info\"><\/i><strong>Important Tip: to keep your changes, create a new branch before exiting the detached HEAD state <\/strong><\/p>Commits created in a detached head state are not associated with any branch and may be garbage collected by Git after you checkout a branch. That is why to keep your changes, it is recommended to create a new branch before checking out a branch. For example, commits C5 and C6 will be garbage collected if we check out Main without creating a new branch.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/detachedHeadCommits.png\"><img decoding=\"async\" class=\"size-medium wp-image-235865 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/detachedHeadCommits-300x211.png\" alt=\"Image detached head commits\" width=\"300\" height=\"211\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/detachedHeadCommits-300x211.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/detachedHeadCommits.png 663w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>To learn more about the detached head state view the following Git documentation: <a href=\"https:\/\/git-scm.com\/docs\/git-checkout#_detached_head\" target=\"_blank\" rel=\"noopener\">Detached Head<\/a><\/p>\n<p><\/div><\/p>\n<p>Checking out the tip of a remote branch can be helpful if you would like to quickly review a pull request and evaluate the latest updates. To do that in Visual Studio, first make sure to fetch and get the latest updates from your remote repository <strong>Git &gt; Fetch<\/strong>. Then right click on the remote branch you would like to review and select <strong>Checkout Tip Commit<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Tip-Commit.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235787 size-large\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Tip-Commit-1024x477.png\" alt=\"Image Checkout Tip Commit\" width=\"640\" height=\"298\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Tip-Commit-1024x477.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Tip-Commit-300x140.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Tip-Commit-768x357.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Tip-Commit-1536x715.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Checkout-Tip-Commit.png 1637w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><div class=\"alert alert-primary\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Info\"><\/i><strong>Note: Uncommitted changes might conflict with the commit you are checking out<\/strong><\/p>You can checkout commits and branches when you have uncommitted changes. Visual Studio detects if there are conflicts between uncommitted changes and the commit\/branch you are checking out and provides an option to keep your changes by reapplying them after the checkout.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkout-with-changes.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235887\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkout-with-changes-300x195.png\" alt=\"Image checkout with changes\" width=\"450\" height=\"292\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkout-with-changes-300x195.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkout-with-changes-1024x666.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkout-with-changes-768x499.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/checkout-with-changes.png 1080w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p><\/div><\/p>\n<p>&nbsp;<\/p>\n<h3>Multi-repo branching<\/h3>\n<p>During this release we continued improving the <a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/multi-repo-support-in-visual-studio\/\">multi-repo support preview feature we introduced in Visual Studio 2022 Preview 3<\/a> by enhancing the inner loop branching experience. The easiest way to enable multi-repo support is to use CTRL+Q, type \u201cpreview\u201d and open the preview features pane. Scroll to \u201cEnable multi-repo support\u201d and toggle the checkbox.<\/p>\n<p><a style=\"color: #006f94; text-decoration-line: underline; outline-width: 0px;\" href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-flag.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235789 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-flag.png\" alt=\"Image Multi repo flag\" width=\"2500\" height=\"261\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-flag.png 2500w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-flag-300x31.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-flag-1024x107.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-flag-768x80.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-flag-1536x160.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-flag-2048x214.png 2048w\" sizes=\"(max-width: 2500px) 100vw, 2500px\" \/><\/a><div class=\"alert alert-primary\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Info\"><\/i><strong>Note: Open a solution with projects hosted on different Git repositories to get started <\/strong><\/p>Once you enable the multi-repo feature flag and open a solution <strong>File &gt; Open &gt; Project\/Solution<\/strong> with projects hosted on different Git repositories, Visual Studio will automatically activate up to 10 repositories at the same time.<\/div><\/p>\n<p>The branch pickers on both the status bar and the Git Changes tool window now support multi-repo in Visual Studio. You can utilize them to quickly switch between branches and do lightweight branch management across all of your active repositories. To quickly switch between branches of any active repository, expand the repository tree on the branch picker and click on the branch you would like to checkout.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Switch-a-branch-in-multi-repo.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235795\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Switch-a-branch-in-multi-repo-300x175.png\" alt=\"Image switch a branch in multi repo\" width=\"450\" height=\"262\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Switch-a-branch-in-multi-repo-300x175.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Switch-a-branch-in-multi-repo-1024x597.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Switch-a-branch-in-multi-repo-768x448.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Switch-a-branch-in-multi-repo.png 1276w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p>You can use both branch pickers for lightweight branch management across your active repositories. Common inner loop branching operations including merge, rebase, rename, delete and compare branches are accessible by right clicking branches on this list. For more advanced repository and branch management operations please use the <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/version-control\/git-manage-repository\">Git Repository window<\/a>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Light-branch-management.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235800\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Light-branch-management-300x189.png\" alt=\"Image light branch management\" width=\"450\" height=\"283\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Light-branch-management-300x189.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Light-branch-management-1024x644.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Light-branch-management-768x483.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Light-branch-management.png 1316w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-checkout.gif\"><img decoding=\"async\" class=\"aligncenter wp-image-235981 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Multi-repo-checkout.gif\" alt=\"Multi repo branching\" width=\"1600\" height=\"876\" \/><\/a><\/p>\n<p>A popular use case for this lightweight branch management experience is to include updates from different remote branches. For example, to merge changes from a colleague&#8217;s branch, right click on the branch under the Remotes tab and select <strong>Merge into Current Branch<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Merge-a-remote-branch.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235802\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Merge-a-remote-branch-278x300.png\" alt=\"Image merge a remote branch\" width=\"300\" height=\"324\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Merge-a-remote-branch-278x300.png 278w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Merge-a-remote-branch-949x1024.png 949w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Merge-a-remote-branch-768x829.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Merge-a-remote-branch.png 1008w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The create new branch experience now supports creating branches across all active repositories. All you need to do is provide a branch name and click the <strong>Create branches<\/strong>\u00a0button to create the same new branch on all active repositories! You can also choose to create your new branch on a subset of active repositories by utilizing the checkboxes.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235806 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-1.png\" alt=\"Image create multi repo branches\" width=\"2310\" height=\"896\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-1.png 2310w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-1-300x116.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-1-1024x397.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-1-768x298.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-1-1536x596.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-1-2048x794.png 2048w\" sizes=\"(max-width: 2310px) 100vw, 2310px\" \/><\/a><\/p>\n<p>If you need your new branches to be based on branches other than your currently checked out branches, you can utilize the branch drop-down to do that. For example, let\u2019s say we need our new branch to be based on the subtract_feature branch on the MathLib repo and based on a different branch on the Multi-rep Calculator repo. In this case, we would use the branch drop-down to select a different branch under the Multi-rep Calculator repo.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-2.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235807 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-2.png\" alt=\"Image create multi repo branches 2\" width=\"2282\" height=\"1174\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-2.png 2282w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-2-300x154.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-2-1024x527.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-2-768x395.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-2-1536x790.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Create-multi-repo-branches-2-2048x1054.png 2048w\" sizes=\"(max-width: 2282px) 100vw, 2282px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Line-staging (interactive staging)<\/h3>\n<p>Line-staging support, a.k.a. interactive staging is one of our <a href=\"https:\/\/developercommunity.visualstudio.com\/t\/git-stage-selected-portion-of-file\/443834\">most popular Git suggestion tickets<\/a>. Line-staging can be helpful when you need to split changes across different commits. This preview includes few of the Line-staging features that we are still working on enhancing. The easiest way to enable this early version of line-staging support is to use CTRL+Q, type \u201cpreview\u201d and open the preview features pane. Scroll to \u201cEnable line-staging support\u201d and toggle the checkbox.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Line-staging-feature-flag.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235809 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Line-staging-feature-flag.png\" alt=\"Image Line-staging feature flag\" width=\"2458\" height=\"198\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Line-staging-feature-flag.png 2458w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Line-staging-feature-flag-300x24.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Line-staging-feature-flag-1024x82.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Line-staging-feature-flag-768x62.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Line-staging-feature-flag-1536x124.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Line-staging-feature-flag-2048x165.png 2048w\" sizes=\"(max-width: 2458px) 100vw, 2458px\" \/><\/a><div class=\"alert alert-primary\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Info\"><\/i><strong>Note: line-staging is still a preview feature<\/strong><\/p>This functionality is still a preview feature, which means we are working hard to add more support in the coming releases. In the meantime, we\u2019re depending on your feedback, the community, to build what you need<\/div><\/p>\n<p>Once you switch on the line-staging preview flag and restart your Visual Studio, you can start staging chunks of your changes by clicking on files in the <strong>Git Changes window<\/strong>. Then hover over the sections of code you would like to stage and click <strong>Stage Change<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235816 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line.png\" alt=\"Image staging a line\" width=\"2430\" height=\"725\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line.png 2430w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-300x90.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-1024x306.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-768x229.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-1536x458.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-2048x611.png 2048w\" sizes=\"(max-width: 2430px) 100vw, 2430px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staged-a-line.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235818 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staged-a-line.png\" alt=\"Image staged a line\" width=\"2686\" height=\"801\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staged-a-line.png 2500w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staged-a-line-300x89.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staged-a-line-1024x305.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staged-a-line-768x229.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staged-a-line-1536x458.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staged-a-line-2048x611.png 2048w\" sizes=\"(max-width: 2686px) 100vw, 2686px\" \/><\/a><\/p>\n<p><div class=\"alert alert-success\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Lightbulb\"><\/i><strong>Tip: use line-staging with your preferred diff layout<\/strong><\/p>Line-staging is supported on both inline and side-by-side diff modes:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-in-line-view.png\"><img decoding=\"async\" class=\"aligncenter wp-image-235820 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-in-line-view.png\" alt=\"Image staging a chunk in line view\" width=\"2386\" height=\"744\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-in-line-view.png 2386w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-in-line-view-300x94.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-in-line-view-1024x319.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-in-line-view-768x239.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-in-line-view-1536x479.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/12\/Staging-a-line-in-line-view-2048x639.png 2048w\" sizes=\"(max-width: 2386px) 100vw, 2386px\" \/><\/a><\/div><\/p>\n<p>This early version of line-staging support has a number of known issues and limitations.<\/p>\n<p><strong>Known Issues:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/developercommunity.visualstudio.com\/t\/Missing-the-ability-to-stage-specific-li\/1610787\">Missing the ability to stage specific lines within chunks or sections of changes<\/a><\/li>\n<li><a href=\"https:\/\/developercommunity.visualstudio.com\/t\/Can%E2%80%99t-stage-lines-at-the-first-and-last\/1610794?entry=myfeedback\">Can\u2019t stage lines at the first and last three lines of code in documents<\/a><\/li>\n<\/ul>\n<p><strong>Upcoming features:<\/strong><\/p>\n<ul>\n<li>Ability to stage lines and chunks of code directly from the editor<\/li>\n<li>Ability to un-stage lines and chunks of code<\/li>\n<li>Refresh latency enhancements<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3>Let us know what you think<\/h3>\n<p>We have benefitted greatly from all the rich feedback we\u2019ve received from you \u2013 thank you! We hope you\u2019ll help us continue to improve by giving the new multi-repo preview feature a try and letting us know what you think by taking the following quick survey:<\/p>\n<p style=\"text-align: center;\"><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/www.surveymonkey.com\/r\/JS3KN7Q\" target=\"_blank\">Share Your Feedback<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We continue to enhance the Git experience in Visual Studio, and we are excited to announce some long-awaited updates in version 17.1 Preview 2. Download the latest Visual Studio Preview and check out the following new Git features. New Git features Description Compare branches Compare your checked out branch with any local or remote branch. [&hellip;]<\/p>\n","protected":false},"author":4322,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155],"tags":[237,1396,510,431,4381,6815],"class_list":["post-235744","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","tag-net","tag-azure-devops","tag-cpp","tag-git","tag-github","tag-visual-studio-2022"],"acf":[],"blog_post_summary":"<p>We continue to enhance the Git experience in Visual Studio, and we are excited to announce some long-awaited updates in version 17.1 Preview 2. Download the latest Visual Studio Preview and check out the following new Git features. New Git features Description Compare branches Compare your checked out branch with any local or remote branch. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/235744","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/4322"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=235744"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/235744\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=235744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=235744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=235744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}