VS Code has 5000 files that need to be commit

VS Code has 5000 files that need to be commit
0

#1

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!

-Silas


#2

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.


#5

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,
-Silas


#6

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:

.gitignore
node_modules

#7

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


#8

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

Thanks you,
Silas


#9

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.


#10

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).


#11

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.


#12

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,
Silas


#13

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.


#14

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!

Silas