8

My solution involves three Git repositories in a self-hosted Bitbucket Server. One repository for the iOS project, one repository for the shared project type such as libraries shared among other projects like Android, and then the company shared repository with more class libraries not project specific.

In Visual Studio 2015 I could go to the Team Explorer and connect to the various repositories, so I could view the commit history and have source control access to commit or pull from Git. In Visual Studio 2017 when I connect to one of the other repositories I am taken out of my solution back to the start page.

How can I manage multiple repositories that make up one Visual Studio 2017 solution? My only option right now is using an external tool such as Sourcetree.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Neal
  • 9,487
  • 15
  • 58
  • 101
  • If *everyone* working on this project needs to have access and/or make changes in all three repositories, one way is to use submodules - one repository is the "main" one, and and the libraries are pulled in as submodules (although this is not without caveats and workflow issues specific to submodules). https://git-scm.com/docs/git-submodule – crashmstr May 02 '17 at 14:21
  • For VS2015, you can clone multiple repos from bitbucket to local, but you can only work with one repo for a moment. And so for VS2017. So what do you mean to manage multiple repos in VS2015? – Marina Liu May 02 '17 at 14:28
  • In VS 2015 I could switch between the active repo that VS offered source control options, VS 2017 doesn't do this so I cannot manage my other two repos at all in VS 2017. Git submodules and subtrees are not an option, we tried that initially and it just raised more complications for managing the repos. – Neal May 02 '17 at 14:30
  • Can you show the detail steps that how did you use source control options to switch repos in VS2015? – Marina Liu May 02 '17 at 14:47
  • The same, use Team Explorer, Manage Connections, double-click on one of the listed repos. I set the folder location in the main Team Explorer settings for Git (D:\Dev has all the repo folders). So all repos are listed, I just cannot change between them and keep the same solution that's opened open for continued use. The solution gets closed when changing connections (repos) which was not the case in VS 2015, it worked then. – Neal May 02 '17 at 14:49
  • @chadbo asked: To help us understand your scenario when we do consider the multi-repo feature, can you explain to me how you coordinate changes in those three repos? Do you have some pointer file in the repo that specifies which commit should be used in the other repos? If not, how do you keep the three repos in sync for builds, hotfixes, etc. – jessehouwing May 22 '17 at 16:09
  • @neal answered: I suggest refer to Xamarin Studio (Mac) as they have always handled this. The Solution/File Explorer needs to be able to handle multiple repos. I should be able to check for changes per se on a project and it knows what repo it belongs to and that repo's changes are handled, presented, etc. Any file you act on (right-click) the solution explorer should know what repo it is in and handle changes. As I don't use team services I should never need to be in the Team Explorer for anything. – jessehouwing May 22 '17 at 16:12
  • Support for this is finally on the official VS RoadMap: https://developercommunity.visualstudio.com/idea/521291/vs2019-multiple-git-repositories-to-be-active-at-o.html – McGuireV10 Nov 14 '19 at 13:40

3 Answers3

3

The design for Team Explorer has always been to close the solution if the containing Git repository was closed and a different repository was opened. If you were seeing different behavior in Visual Studio 2015, it was unintentional.

We would like to support multiple Git repositories open at the same time in Team Explorer, but that feature has not yet been added.

The Team Explorer extension provides the Git integration for Visual Studio. Regardless of whether you use VSTS or not, you'll still use Team Explorer for Git operations in the IDE. I completely agree that it would be great to support multiple repositories for a single solution. Features are prioritized and this one simply hasn't been built yet.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Chad B
  • 1,416
  • 9
  • 12
  • Thank you, I suggest refer to Xamarin Studio (Mac) as they have always handled this. The Solution/File Explorer needs to be able to handle multiple repos. I should be able to check for changes per se on a project and it knows what repo it belongs to and that repo's changes are handled, presented, etc. Any file you act on (right-click) the solution explorer should know what repo it is in and handle changes. As I don't use team services I should never need to be in the Team Explorer for anything. – Neal May 02 '17 at 16:12
  • The Team Explorer extension provides the Git integration for Visual Studio. Regardless of whether you use VSTS or not, you'll still use Team Explorer for Git operations in the IDE. I completely agree that it would be great to support multiple repos for a single solution. Features are prioritized and this one simply hasn't been built yet. – Chad B May 02 '17 at 16:13
1

This is currently still unsupported so you will have to drop out to the command line or open multiple instances of Visual Studio.

However, support for this feature has been reported as "planned" and you can vote to increase the priority of this feature on the Visual Studio User Voice site.

SensorSmith
  • 1,129
  • 1
  • 12
  • 25
0

Both Visual Studio 2015 and Visual Studio 2017 will close a solution if you switch to another Git repository. But you can open three Visual Studio windows to handle these three git repositories at the same time.

Assume the three Git repositories located in D:\Dev\git1, D:\Dev\git2 and D:\Dev\git3, and Visual Studio (works both for Visual Studio 2015 and Visual Studio 2017) is connect with D:\Dev\git1.

You can connect git2 by opening the folder D:\Dev\git2 in Windows Explorer, and open .sln file in D:\Dev\git2 by the same version of Visual Studio, and then Visual Studio will connect with D:\Dev\git2 in another Visual Studio window. You can connect with D:\Dev\git3 by the same way. And you will find three Visual Studio windows opened to connect with the three Git repositories.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • The problem is we keep the .sln files in a separate folder in one of the repos. I guess I can try copying that solutions folder into all three repos and see if that works. – Neal May 09 '17 at 11:10
  • 2
    You can also use `git subtree add --prefix=git2/ master ` if you are used to git commands. – Marina Liu May 10 '17 at 07:55