I have a project containing multiple other projects :
All containing <
Add this
node_modules/
to .gitignore file to ignore all directories called node_modules in current folder and any subfolders
Try doing something like this
**/node_modules
** is used for a recursive call in the whole project
Two consecutive asterisks
**in patterns matched against full pathname may have special meaning:A leading
**followed by a slash means match in all directories. For example,**/foomatches file or directoryfooanywhere, the same as patternfoo.**/foo/barmatches file or directorybaranywhere that is directly under directoryfoo.A trailing
/**matches everything inside. For example,abc/**matches all files inside directoryabc, relative to the location of the .gitignore file, with infinite depth.A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example,
a/\**/bmatchesa/b,a/x/b,a/x/y/band so on.Other consecutive asterisks are considered invalid.
Reference
First and foremost thing is to add .gitignore file in my-app. Like so in image below.
and next add this in your .gitignore file
/node_modules
You can also add others files too to ignore them to be pushed on github. Here are some more files kept in .gitignore. You can add them according to your requirement. # is just a way to comment in .gitignore file.
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Adding below line in .gitignore will ignore node modules from the entire repository.
node_modules
Create .gitignore file in root folder directly by code editor or by command
For Mac & Linux
touch .gitignore
For Windows
echo .gitignore
open .gitignore declare folder or file name like this /foldername