Git - Ignore node_modules folder everywhere

Question

I have a project containing multiple other projects :

  • Main project
    • Mini project 1
    • Mini project 2

All containing node_modules folder. I want git to ignore the folder no matter where it is starting from the root folder. Something like this to add in .gitignore :

*node_modules/*

Answer

Add node_modules/ or node_modules to the .gitignore file to ignore all directories called node_modules in the current folder and any subfolders like the below image.

example

What are the differences between .gitignore and .gitkeep?

git pull fails "unable to resolve reference" "unable to update local ref"