Multi-repo Support in Visual Studio
Have you ever needed to work on a solution with projects hosted on different Git repositories? Previously, you had to either use multiple instances of Visual Studio or rely on external Git tools. Starting with Visual Studio 2022 Preview 3, you can enable the multi-repo support preview feature which will enable you to work with a single solution with projects in multiple repositories and contribute to them from a single instance of Visual Studio.
The easiest way to enable multi-repo support is to use CTRL+Q, type “preview” and open the preview features pane. Scroll to “Enable multi-repo support” and toggle the checkbox. 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’re depending on your feedback, the community, to build what you need.
Open solution with projects in different repositories
If you already have a solution with projects hosted on different Git repositories, just open your solution using Visual Studio’s Start Window or using File > Open > Project/Solution and Visual Studio will automatically activate up to 10 repositories at the same time. You will be able to tell if Visual Studio has activated your different Git repositories by looking at the repository picker on the status bar (located at the lower right corner), which will tell you the number of active repositories you have. Active repositories show bolded on the repository picker.
You can also add projects hosted on different repositories to your existing solution by right clicking on your solution in Solution Explorer and selecting Add > Existing Project.
The Git Changes Window will automatically track changes cross repositories. All you need to do is write a commit message and click the “Commit All Repos” button for all of your changes to be committed. You can also choose to stage your changes first which enables you to choose the repositories you would like to commit to. Alternatively, you can use the repository picker at the top of the Git Changes window to focus on and commit changes to one repository at a time.
Amend, Stash, Branch switching & Network operations
Multi-repo support for Amend, Stash, Branch switching and network operations including Pull, Push, Fetch and Sync is coming to the Git Changes window in future iterations. To use any of these operations now, you will have to use the repository picker to focus on one repository at a time. Alternatively, for branching you can rely on the Git Repository Window as demonstrated in the following section.
Branch & Repository Management
The Git Repository window recognizes all active repositories and provides cross repository browsing and management experience. You can preview, create, manage, and switch branches right from this window. Commit details, embedded diff and incoming/outgoing commits all function as they do with single repositories.
Let us know what you think
We have benefitted greatly from all the rich feedback we’ve received from you – thank you! We hope you’ll 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:
This is a jewel! Because of this feature I’ll probably sacrifice the support for my favorite extensions which aren’t available yet and start using 2022 for our production workloads
Happy to hear that you like this feature Paul! I look forward to your feedback on how we can improve it.
I found there is one disappointing limitation: it does not work in “folder” mode. To be precise, the local repository detection does not work at all in folder mode, or at least only some repositories in subfolders are found when you “open a folder”.
Been psyched for this for years. Change detection seems to work in submodules with preview 3 and multi repo on! And multi repo committing seems sweet, I’ll try that for real tomorrow.
Unfortunately doing a right mouse git->”view history ” gives me an empty history for any file in a submodule 😢 is this by design?
Really promising so far!
Great to hear that you like it so far Joris!
The issue you described is not by design. We will look into it and see what we can do. Maybe a work around for now would be to use the Git Repository Window instead. Please continue to share your feedback. We’d appreciate it if you can also take the survey once you get a chance to use it more.
I have the same problem with history.
Also, I’m my case Visual studio shows only one repo.
I found that Visual Studio does not recognize another repository if it does not contains csproj file.
I mostly work with Unity. And Unity generates all csproj files automatically and they are not part of the repo. All csproj files are located in the project root and I can’t change their location.
Some of csproj use files from submodules.
Solution explorer looks like this: https://imgur.com/a/9GWkqFJ
Thank you, this has been a long awaited feature. the suffering that i had to go through to commit my submodule changes was unbearable.
Thanks smart programmer. Please feel free to provide feedback as you get to try this feature.
Any information on how this will be supported in Azure DevOps or perhaps there are no plans ATM?
This feature could help me as I currently have different DevOps projects with private artifacts, would be nice to have a single solution.
Thanks Dawson, this feature works on all Git providers including Azure DevOps. Give it a try and let us know what you think.
What a great news!
In the article I have noticied that:
Visual Studio will automatically activate up to 10 repositories at the same time
Are you going to remove the number of repos limitation in the next release?
In our codebase we have a lot of solutions which are using more than 10 repositories at the same time.
It would be awesome if there were any limitation on the number of repos loaded in the same solution soon
Thanks for the feedback Daniele, it would be great to learn more about the gap you have with the current implementation. How many projects that the current implementation is not allowing you to activate? Performance is something we are keeping any eye on that is why we have this limitation in place.
I was very excited to see this feature, but it appears it does not support submodules?
Any chance of this being back ported to 2019?
Thanks for participating Angelico. There are no current plans to back port this preview feature to VS2019. Our current goal is to get this feature to the quality that would make it possible to release it in VS 2022. That is why we need your feedback. We would appreciate it if you can try this preview feature in VS2022 preview and let us know what you think.
Not a big deal actually. I see no reason at all to work with Git from VS – hell WHY?? There is tens of tools (inc. open source) which do the job MUCH BETTER, including multiple repos. So question: why you WASTE TIME on functionality, which already exists?? Visual Studio has A LOT of issues and bugs, isn’t it better to fix ’em instead of creating unnecessary “integration”? IDE doesn’t mean you have to put EVERYTHING in one shell! Even car mechanic never uses “universal screwdriver” – they have ten different screwdrivers for every type of work and EACH OF THEM works perfect. Opposite to VS which does everything, but on average level.
My solution contains C++ and C# projects.
Git Changes only shows changed C++ files until they are saved. Once saved, the C++ files disappear from the Changes list.
Changed C# files are displayed as expected.
Actually, restarting the vs2022 IDE seems to display all changed files properly. So the new, multi-repo feature can still be used. 🙂
How can you manage the dependency between projects when you have one project per repository?
Is this feature also going to bind the SCM type to the Solution?
We work with solutions that are managed by Subversion AND other solutions that are Git-based.
Currently with VS up to 2019 we have to open a blank instance, go to preferences, change the SCM type, close VS, then finally double click on the solution that we need to open. It would be nice if VS knew that a certain solution uses a certain SCM.