- Check for an existing
.gitignore
file in the project directory
ls -a
- If your project directory has a
.gitingore
file - skip to step 3. Otherwise, continue with:
Create a .gitignore
file in the git repository
touch .gitignore
- Open up the
.gitignore
and add the following line to the file
**/node_modules
- Remove the
node_modules
folder from the git repository
git rm -r --cached node_modules
- Commit the git repository without the
node_modules
folder
git commit -m "Removed node_modules folder"
- Push the change to the remote repo
git push origin main
- Commit the
.gitignore
file
git add .gitignore
git commit -m "Updated the .gitignore file"
git push origin main
@BekzodIsakov A leading
**/
in a.gitignore
file will allow files and folders to be ignored in the current or any descendant directory rather than just the current directory. This is useful in apps with separate packages for the client & server, for example.If I have a directory structure like
The
**/node_modules
will still ignore the node_modules folder.The
**/
is not necessary if only the node_modules folder will be at the same level as the.gitignore
file.