Let's say I have the following structure:
my-project
├── modules
│ ├── my-first-module
│ ├── my-second-module
│ └── my-fourth-module
I included the modules directory in my .gitignore file and made an exception for my-third-module:
/my-project/modules/*
!/my-project/modules/my-third-module/
Then when I execute git submodule add git@git.my-app/my-third-module.git
from my-project/modules/ path, I get:
The following path is ignored by one of your .gitignore files:
my-project/modules/my-third-module
Use -f if you really want to add it.
It seems the exclusion of /my-project/modules/my-third-module/
in .gitignore is not taken into account.
So, I tried to create an empty my-third-module directory but in this case the git submodule add
command complains:
'my-third-module' already exists and is not a valid git repo
Apparently git submodule add
requires that the directory doesn't exists, so it's not the way to go.
Why the exclusion of my-third-module is not taken into account by Git?