Version control changes window shows files that are ignored
Answered
I'm using git for source control on Javascript/node projects. One project is npm linked into the node_modules directory of the other project.
Eg.
src/ProjectA
src/ProjectB
src/ProjectA/node_modules/ProjectB
I open ProjectA and B as separate IntelliJ projects.
node_modules is .gitignored, and IntelliJ shows this by greying it out.
However, when there are files changed in ProjectB the version control window in ProjectA shows those files:
Default:
File.js ~/src/ProjectA/node_modules/ProjectB/File.js
Yes they are under the ProjectA directory, yes they are controlled by git, but not in this project!
If I click the button to commit changes they will be included, which again, is wrong.
Please sign in to leave a comment.
How many git repositories do you have? Is there a separate git repo for each project, or a single repo in the src folder?
Hi, should have added that..
They are separate git repositories. So there is a ProjectA/.git and a ProjectB/.git
In general I have the two projects open in separate IntelliJ windows, although I don't need to have ProjectB open to see the ProjectB files show up in ProjectA
Check Version control mappings in Settings - Verison control node. Looks like for some reasons in both Projects you have both repositories registered as roots.
Make sure that in the ProjectA you have only src/ProjectA registered, and in the ProjectB you have only src/ProjectB.
If there is just a <Project> mapping, please substitute it with explicit paths to the corresponding git repo.
Thanks, that was it. My structure is actually about 5 projects, but in the simple example given...
In that setting ProjectA had:
<Project>
/Users/martin/src/ProjectA
node_modules/ProjectB (/Users/martin/src/ProjectA)
I have never added this myself, do they get there from some kind of scan when opening the project?
Root is added automatically only if there are no other entries in Settings, and there is a single root in the project. Since you have several entries, doesn't look like it.
What could happen though, is the following:
1. You open another project in the same windows (e.g as a module, or using other means)
2. A notification appears that unregistered root is found
3. You click Add there
4. You close the second project (remove the module, etc)
5. Mapping is not removed automatically