1

I am working on a git branch and I'm using VS Code to track any changes I make to the branch.

However, when I ran npm install, VS Code started to track node_modules which has 850+ changes.

I've added it to .gitignore file but there is no change so far.

enter image description here

1 Answers1

4

make sure your .gitignore file is in the same parent directory as the node_modules folder.

project_directory
  - .gitignore
  - node_modules
  - other files

you might also checkout: Git - Ignore node_modules folder everywhere

andersryanc
  • 939
  • 7
  • 19
  • I'll try this out; I've accidentally commited and there's no changes to be tracked. – Christopher Kinyua Nov 02 '20 at 06:38
  • 1
    oh yep! once you commit a file it becomes tracked by git no matter what... so as the others have mentioned in the comments on your question, you have to remove the file(s) and then ignore them for it to stick. – andersryanc Nov 02 '20 at 16:59
  • Exactly! Thank was actually what the issue was. Thank you for your answer as well. I moved the file from the root folder and now it is working. – Christopher Kinyua Nov 03 '20 at 11:18