I've set a global .gitignore like this
# global .gitconfig
[core]
quotepath = false
excludesfile = ~/.gitignore_global
Where ~/.gitignore_global
is something like this:
# https://www.gitignore.io/api/pycharm
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/vcs.xml
.idea/**/jsLibraryMappings.xml
# .idea/**/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
So now whenever I start a new project with any intellij IDE only some files inside the .idea
folder will be tracked and others won't. So fa so good.
The problem comes from a project I had started before setting up the .gitignore_global. In fact within this project I had setup a local .gitignore to ignore the .idea/
folder altogether.
# local .gitignore created before the global one
*.idea/
Now, for that old project I want to start to track the relevant files within the .idea
folder, so I've commented the line # *.idea/
.
And here starts the problem.
Instead of just tracking the relevant files as stated in .gitignore_global
it mark as new file (unstaged) ALL the files within the .idea folder, ignoring the .gitignore_global
(sorry for the redundancy).
I suspect (not sure) that back then, years ago I had accidentally added the .idea
folder to the repo, then removed, then ignored.
How can I fix this? I want to track only the relevant files in .idea not marked as ignored by following the instruction from .gitignore_global
.
EDIT: the important part is that git let me add all the new files to the staging area even the ones t not supposed to.
It turned out that I had 2 .idea/
directories.
One was create by pycharm at the first level, where also the .git
dir lives and the other one buried down several levels targeting my webapp created by webstorm.
The one at the first level was correctly adding/ignoring files, the one deep down wasn't.
The trivial reason was that regexs like this .idea/**/workspace.xml
on my global gitignore were only targeting first level dir.
To make this work wherever the .idea dir would live inside my repo I had to change those regexs to the form **/.idea/**/workspace.xml
.