Difference between ** and * in glob matching (.gitignore)
There are two approaches for this type of situation, depending on your needs.
One solution is to put
# generated files*.js
in pw-spec/.gitignore.
The second solution is to put:
/pw-spec/*.js/pw-spec/*/*.js/pw-spec/*/*/*.js
and so forth in the main .gitignore file.This approach is brittle if more sub-directories are added.
I generally prefer to put the .gitignore file at the same level as the Makefile which generates the files that I am ignoring.
The difference is that **
doesn't work, at least not for everyone. See
Why doesn't gitignore work in this case?
You can have a separate .gitignore
in pw-spec/
Create a .gitignore
in pw-spec
in which you insert these two lines:
*.js*/*.js
Also note that if you already have files tracked in this subdirectory which you want "untracked", you have to make them unknown to the index as such:
git rm --cached path/to/file
For instance, if in directory pw-spec
you can do:
find -type f -name "*.js" | xargs git rm --cached