Using Git across multiple modules?

I have a problem with using Git inside IDEA  on our current project.    

This Maven-based project is organized into three "sub projects" inside a single Git repository:

/MyProject
--- /SubprojectMain
---/SubprojectOther
---/SubprojectWeb


So the Git repo itself lives in folder "MyProject" but each pom.xml file lives in its own subfolder, for example /MyProject/SubprojectMain/pom.xml.

The "SubprojectMain/pom.xml" includes the other two projects, making it the "parent pom", but the Git plugin in IDEA sees each subfolder as a separate project.   The problem with this is that if I change files in two or three projects, and then do a "commit", I have to remember (each time!) to manually select files in the other two projects besides the one I've clicked on.   Otherwise they don't get committed.

Is there any way to force the Git plugin to "recognize" all three folders as a single project?   I've checked the settings pages and don't see anything, but if someone has an answer for this it would be great.

4 comments
Comment actions Permalink

Hi Tom,

What do you exactly mean by "Git plugin in IDEA sees each subfolder as a separate project"? Maybe attach a screenshot to clarify this.

If you go to the Settings | Version Control and add the path to your Git repository there, it should show be able to work will this repository, including all subfolders.

0
Comment actions Permalink

I checked my File/Settings/Version Control and verified that the correct repo folder was added.    The problem, I think, has something to do with the fact that the repository root is in the parent folder but the Maven "parent pom" is in one of the subfolders.

Here are some screenshots showing the location of the git repository in relation to the pom files, and the way Intellij is looking at the modules in the project:



Attachment(s):
ij3.jpg
ij2.jpg
ij1.jpg
0
Comment actions Permalink

egearbox wrote:

Is there any way to force the Git plugin to "recognize" all three folders as a single project?  

Your screen shot shows a single project with three modules. IDEA always shows a single project in a window. It will never show two projects in a window.

That said, it does look like there is some configurations issues. I notice there is a .idea project directory in both the project root directory (based on screenshot 2) and in the FirstCallOnline directory (based on screenshot 1).

egearbox wrote:

The problem with this is that if I change files in two or three projects, and then do a "commit", I have to remember (each time!) to manually select files in the other two projects besides the one I've clicked on.   Otherwise they don't get committed.

I think the issue may be how (or from where) you are triggering a commit. you commit via the context menu in the project tool window, you will have to commit each module separately since there is no "parent" node to select. The best way to commit is to either:

  1. Use the VCS Operations Popup (Alt+` (That's the back quote) or V (Mac) or from the menu, VCS > VCS Operation Popup) and select "Commit Changes...". That will commit all changes in the current project (i.e. in all three modules). Be sure to use "Commit Changes..." as the "Commit File..." option will only have the current files selected in the commit dialog.
  2. From the Changes Tool Window by selecting the changeset, opening the context menu and select "Commit Changes"


0
Comment actions Permalink

markv wrote:

egearbox wrote:

Is there any way to force the Git plugin to "recognize" all three folders as a single project?  

Your screen shot shows a single project with three modules. IDEA always shows a single project in a window. It will never show two projects in a window.

That said, it does look like there is some configurations issues. I notice there is a .idea project directory in both the project root directory (based on screenshot 2) and in the FirstCallOnline directory (based on screenshot 1).

egearbox wrote:

The problem with this is that if I change files in two or three projects, and then do a "commit", I have to remember (each time!) to manually select files in the other two projects besides the one I've clicked on.   Otherwise they don't get committed.

I think the issue may be how (or from where) you are triggering a commit. you commit via the context menu in the project tool window, you will have to commit each module separately since there is no "parent" node to select. The best way to commit is to either:

  1. Use the VCS Operations Popup (Alt+` (That's the back quote) or V (Mac) or from the menu, VCS > VCS Operation Popup) and select "Commit Changes...". That will commit all changes in the current project (i.e. in all three modules). Be sure to use "Commit Changes..." as the "Commit File..." option will only have the current files selected in the commit dialog.
  2. From the Changes Tool Window by selecting the changeset, opening the context menu and select "Commit Changes"





Yes, I'm afraid this project has undergone numerous changes over its lifespan.     :_|   

I'll eventually get around to making a new folder and cloning a new copy of the Git repo, but thank you for letting me know some workarounds in the meantime!   I will use those until the project can be fixed.

0

Please sign in to leave a comment.