DEV Community

Cover image for GIT :: ignoring files/folders recursively
Ande Caleb
Ande Caleb

Posted on

GIT :: ignoring files/folders recursively

I had a folder for a particular set of Web Applications projects grouped together under one repository, instead of having separate repositories per project, below is my illustration.

lets say i had 5 web projects in one repository prefixed by _1, _2, or _3. and each of these projects have their individual dependencies inside the node_modules folder.

with just one .gitignorefile

repo/WebApp_1/node_modules/*/*/*.js
repo/WebApp_2/*/node_modules/*/*/*/*.js
repo/WebApp_3/*/*/node_modules/*/*/*/*/*.js
repo/WebApp_4/*/*/*/node_modules/*/*.js
repo/WebApp_5/*/*/*/*/*/node_modules/*/*.js

.gitignore  //just one gitignore file here.

Enter fullscreen mode Exit fullscreen mode

I initially thought i could use the parent .gitignore file to restrict all node_modules directorys withing the sub directories.

After googling and i figured out that you could have each folder with its individual .gitignore folder to solve the issue.

repo/WebApp_1/ .gitignore
repo/WebApp_2/ .gitignore
repo/WebApp_3/ .gitignore
repo/WebApp_4/ .gitignore
repo/WebApp_5/ .gitignore
Enter fullscreen mode Exit fullscreen mode

this approach worked for me, so i want to know if anyone has a better alternative and a centralized way of achieving this i would be glad to adhere to it.

Thanks.

Top comments (0)