Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Solution from multiple Git repositories

Tags:

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?

like image 796
Samrat Dutta Avatar asked Nov 11 '16 11:11

Samrat Dutta


People also ask

Can I have multiple Git repositories?

With Git, using multiple repositories is the only way to work efficiently. This enables each team to work independently, and do their work faster. You can also make sure that developers only have access to the repositories they need access to (thus making Git more secure.)


1 Answers

You can use submodules to realize it. Treat one repository as mainRepo and the other as subRepo.

  1. Based in the mainRepo and add the subRepo in it, use git submodule add subRepo’s_URL
  2. Just make changes on files you want. You don’t need to pay attention to which repository the files are from
  3. In the local mainRepo, use git commit –a –m ‘input your comment’, and then modified files from mainRepo can be committed
  4. In the subRepo (cd [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.

like image 74
Marina Liu Avatar answered Oct 11 '22 07:10

Marina Liu