Reputation: 1737
We have two different repositories on Git which need to come together to form the solution in Visual Studio.
Files under each project may be from the two different repositories. I need to make sure that when I make changes, it updates the changes in the correct repository (that is, the other repository should not perceive it at all) and also give me an option to add new files to a specific repository.
How can this be achieved, if can be done at all?
Upvotes: 26
Views: 11043
Reputation: 180
I am just poking around to see if using multiple repos is feasible, so I don't know the answer. However, this is an old question and I found this that might help update the answers:
Multi-repo Support in Visual Studio
Upvotes: 0
Reputation: 38136
You can use submodules to realize it. Treat one repository as mainRepo and the other as subRepo.
git submodule add subRepo’s_URL
git commit –a –m ‘input your comment’
, and then modified files from mainRepo can be committedcd [subRepoFolderName]
), you can also use git commit –a –m ‘input your comment’
, so modified files from subRepo can be committed.This may be different from want you thought, but it really saves you from which is the correct repository you want to update the changes in.
For more details about submodules, you can refer to here.
Upvotes: 14
Reputation: 613
It's now easy with the Project Manager extension. (At least this is true in Visual Studio Code, and I suspect it's true in VS, since VS is a super-set of VSC)
This is what I did in VS Code, it should be similar in Visual Studio
Assume you have a Git-type repo set up, and you have a separate and distinct top-level repository for each part of the project that must remain distinct.
In GitHub, (or similar) you create the two repositories needed and import files as necessary.
If the repositories/workspaces already exist on the local development machine, make sure that the repositories are fully up to date.
In Visual Studio code install the Project Manager extension.
On the development machine(s), you create a "top level" folder for the entire project as a whole, then open the folder in VSC.
Then save that folder as a "Project" At this point you should "clone" the repositories to folders inside the top-level project folders. You clone the repositories to a new location because moving repositories is a PAIN IN THE TUSH and causes nothing but trouble.
Save each cloned repository as a "workspace"
At this point, you have a "project" containing two workspaces.
Move any folders/files that don't get cloned to the new repository location as necessary.
Once you do all this, (it's actually easier than it sounds), you have access to both repositories as independent objects, commits go to the correct repository, yet you can work on them side-by-side, (sort of) if you wish. You do this by opening the second workspace into a new window.
Hopefully this helps.
Upvotes: -2