Different repositories for each module in intellij IDEA
Solution 1
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:
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).
Solution 2
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" />
Related videos on Youtube
Comments
-
Artemix almost 2 years
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
?.
-
Artemix over 9 yearsIt's all working now, except the push part. When I select the module and go toVCS->Git->Push it only shows one module, the first one I created when I created the project. The other modules are not in the list, so I can't push the changes. Any idea why this could be happenning?.
-
Bohuslav Burghardt over 9 yearsCould you please update your question with screenshot of your VCS roots configuration and your project structure? Or some information like that. The push dialog works just fine for me (displays commits to push for both modules). My test project structure is
project/{module1,module2}
. -
Artemix over 9 yearsI will, give me a sec.
-
Artemix over 9 yearsSorry I can't upload a screenshot of the entire project structure, because of NDA. About the project structure I can tell you that Ihave one project, that contains 2 modules, the first module works alright, and the second added module is the problematic one. The modules don't share folder paths, I mean, they are in different folders without descendants in common.
-
Bohuslav Burghardt over 9 yearsI understand. Based on your screenshot you might want to try removing the
<Project>
VCS root as it might be overriding the VCS roots for individual modules maybe? I added screenshots of my working setup to the answer, hope it will help -
Artemix over 9 yearsTried that, didn't help, I still see one module, the same as before. I have the same structure as you now. What version of IDEA are you using?, I have 13.1.4 right now, updating to 14 maybe is a good idea?.
-
ycomp about 8 yearsso if you modified 1 file in each module, then do a commit Dialog.. both files are shown.. does this mean that they each get added to their respective git repositories? 1 file to each repository?
-
phil294 over 7 years
define one VCS root per directory
. Did that, and now the root is marked as red and it saysInvalid VCS root mapping: The directory /var/www/html/... is registered as a Git root, but no Git repositories were found there.
.. ?! -
AndyRED almost 6 yearsAny ideas on this. I have managed to add both my modules to CVS Git control but I'm also seeing the Invalid VCS root mapping error.