Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different repositories for each module in intellij IDEA

I'm not sure how to select a different git repo for each different module I have in my IDEA project, I'm not seeing any option for that, all the git options seem to only relate to one git repo.

Is there a way to differentiate them?, so:

(All inside the same project)

Module A -> repo A
Module B -> repo B

?.

enter image description here

like image 324
Artemix Avatar asked Nov 21 '14 15:11

Artemix


People also ask

Can there be multiple repositories for each project?

It is a combination of two Git tools that you can use to manage multiple repositories within one project. The two tools are HelixTeamHub and Helix4Git Do. Here, HelixTeamHub lets you work with multiple repositories, whereas the developers can use Helix4Git to contribute to the sub-projects or repositories.

Can you have multiple 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.)


2 Answers

Go to Settings/Version Control, there you can configure different VCS roots per directory. So in your case define one VCS root per directory containing the module. You should remove the VCS entry <Project> and just add entries for individual modules so that it looks something like this:

VCS config

If you have files modified in several different repositories and hit CTRL+K or otherwise open the commit dialog all changed files will be selected and when you commit your changes a new commit with the same message will be created in all repositories containing the changed files.

If you want to commit files from just a single module either manually select them in the commit dialog or right click your module, go to Git and select Commit Directory.

To push the commits just hit CTRL+SHIFT+K and you should see something like this (notice that both modules are included).

Push dialog

like image 195
Bohuslav Burghardt Avatar answered Oct 30 '22 17:10

Bohuslav Burghardt


You might have to edit the vcs.xml manually:

  • open the vcs.xml of the top module / project

    ex.: ~/[Top module folder]/.idea/vcs.xml
    
  • Add the vcs entry:

    <mapping directory="$USER_HOME$/sub_module01" vcs="Git" />
    <mapping directory="$USER_HOME$/sub_module02" vcs="Git" />
    
like image 42
david m lee Avatar answered Oct 30 '22 18:10

david m lee