DEV Community

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

Posted on

1 1

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.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay