-1

I have a file structure like this

master is: ~/Exercism/javascript

exercise files are:

~/Exercism/javascript/hello-world
~/Exercism/javascript/protein-translation
~/Exercism/javascript/resistor-color
...etc

EACH one of these folders has a node_modules folder that I want to ignore

My .gitignore file is located in:

~/Exercism/javascript

content of .gitignore:

**/node_modules/

git still won't ignore the node_modules folders. Is there something I need to run in git? Is my folder in the right place>

I have not committed anything yet but the repo is initiated

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
clinzy25
  • 91
  • 8

2 Answers2

1

You can simply specify it as node_modules/ in the .gitignore file and it will traverse through your parent folder as well as subfolders and ignore all directories called node_modules in each of your subfolders, as opposed to having to specify .gitignore files in each of your subdirectories.

Hope this helps you. Good day!

Ihan Dilnath
  • 343
  • 2
  • 9
0

Every folder should have a different .gitignore file, since all of those folders are different projects. The fact that makes them different projects is that each of them have a different node_modules folder.

Change .gitignore content to

# dependencies
/node_modules

and put a copy in every folder.

Don Diego
  • 1,309
  • 3
  • 23
  • 46
  • I've done this and its still not working. Git add . starts running though a node_modules folder immediately and I ctrl+c out – clinzy25 Feb 15 '21 at 16:54
  • ok, did you configured ignored files for your pc with `git config --global core.excludesfile ~/.gitignore_global` ? have a look here before launching the command: https://docs.github.com/en/github/using-git/ignoring-files because it depends from what service (github, etc) you use – Don Diego Feb 15 '21 at 17:01
  • resolved, it was still a .txt file – clinzy25 Feb 15 '21 at 17:06