0

In my gitignore file i have tried some many ways of ignoring the node_modules folder

.gitignore - file ./node_modules /node_modules node_modules

project structure

  • node_modules
  • public
  • src
  • .gitignore
driiisdev
  • 45
  • 5
  • 1
    The first question must be: "Did you already do a `git push` and upload the **node_modules**-folder to the remote repository before adding **node_modules** to `.gitignore`?" If yes, the answer from @driiisdev would solve your problem. The explanation WHY, you can read in this [answer](https://stackoverflow.com/a/63093031/12632699) – SwissCodeMen May 23 '22 at 07:49

1 Answers1

1

In cases where /node_modules in your .gitignore file doesn't work, I suggest this:

git rm -r --cached node_modules

enter the above command before you git push to your repositories

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
driiisdev
  • 45
  • 5
  • 1
    Please explain what this *above command* make. Only in this way it will become a qualitative answer. I would never simply implement an order without an explanation, so please add it :-) – SwissCodeMen May 23 '22 at 06:29
  • so in a case where the .gitignore file does not ignore the node_modules folder and you have 'git add .' to stage ur files, the above command should be run before commiting locally and pushed to the repo(i.e the the code should run before git push) – driiisdev May 23 '22 at 11:05