VS Code has 5000 files that need to be commit

I have 5000 files in my version control on Visual Studio Code text editor and I don’t know what to do about it. I have searched for the past d and half and I still can’t figure out what to do.

Any help would be much appreciated. Thank you!


Its because git is tracking for all the files even which are present in node_modules directory.
You have to create a .gitignore file and add node_modules/ inside it to tell git not to track them as they are third party code.

Okay, so problem-- I thought I fixed it but I didn’t. How exactly do I create a .gitignore file and add node_modules/ inside it?

Thank you,

A .gitignore file is just a text file named .gitignore

You should have one in your repository. If you don’t, create one with this text:


file -> new ->call it .gitignore
write the line node_modules/ in it

I have tried that and it keeps saying command not found any reason why?

Thanks you,

If you’re in VS code at the top of your file tree (You may have to hover over it) there are icons to add a file or add a folder. Just click to add a file and name it .gitignore . Don’t forget the period in front!

Then inside your .gitignore file type: node_modules

That should be it. You may want to read up on what files are ok to ignore I keep a notes file with a general list of files I ignore and just copy pasta whenever I need it.

Just FYI. You might also need to refresh the view after you have added the folder to .gitignore. Click the arrow circle button (or restart VS Code).

1 Like

If youve already staged and/or committed your node_modules, you’ll need to tell git to stop tracking those files before it will be ignored by your gitignore file.

1 Like

Hey, so I did exactly what you said but it’s still not working. I also added a slash afterwards because someone else said to add that but that also doesn’t work. Anything I am doing wrong?

Thank you,

You shouldn’t have to add any additional flags like a slash. What you have should work. It won’t delete the files you’ve already pushed however. It will just stop tracking them from whatever point you told it to ignore that file. You can probably just manually delete the node_modules folder from github.

I got it working. I don’t really know what happened but I got the files to go away and I was able to push my project to gitHub. I appreciate all the help.

Thank you!


1 Like

Hi, Am facing the same issue, I tried all the possible way, what said above, but no luck. 5000+ changes of node modules files with changes. Troubles to find the check in the file. Please help

Even if you update your .gitignore after the fact, if git is already tracking the files, it will still continue tracking the same files (ignoring your gitignore)

See @cndragn post above for solution.

Sorry for just getting back with you, but did you figure it out? I have a simple solution that I perform if you haven’t already figured things out.

Hi, I am having the same issue, can you help me?

Hi! Sorry I have been off for quite some while.

if you create a file with .gitignore then type in that file node-modules

thin go into your terminal and cd into your project folder that has your .gitignore file-- type “git init” to initialize your folder. Close out of it and then reopen your folder and those 5000+ files should be gone!


I did this same thing. I had run git init in the home folder by accident. I deleted that folder and didn’t do anything but I also had a yarn folder there. I deleted that and all good. Mistake learned. Make sure you are in the right folder before you run init.

1 Like

Enable hidden file view in your File explorer. Then just delete the “.git” folder present in your other directories if you didn’t create it using ‘git init’


Thank you so much for that! So simple but so important!