VS Code has 10.000 files that need to be commit

Hey,

I have 10.000 files in my version control in VS code and don’t know how to remove them. I found a topic about this on freecodecamp and followed the steps about creating a .gitignore text file with the text "node_modules/ inside it. I saved this in the same folder as my .gitconfig file is in (C:/users/myusername/. Is this the folder where my repository is in?

There is still nothing happening. Have I saved the .gitignore file in the right place? are there any other steps I can make?

This message show up when I open VS code.
“The git repository at ‘c:\Users\kommu’ has too many active changes, only a subset of Git features will be enabled.”

Would appreciate any feedback about this.

Annika

you need to delete the .git file that was created when you initialized git, and use the git init command only inside the folder where you are creating your project. Right now git is tracking all your files

2 Likes

Hi @AnnikaB, welcome to the forum.

A couple of things:

1 - you should add version control only to the files you actively want to track.
This means that in general you want to think about “projects” and how they are scoped.
For example:

Folder/
  ProjectA/
  ProjectB/
  ProjectC/

I have two options:
1 - Init Folder as a git project, meaning that it will track all of the files contained in the 3 folders as part of the same project

2 - init each Project separately as individual project.

Seeing that git is complaining about too many files, are you sure you have init the correct folder?
Or in other word, are you sure you are not tracking your whole C:/users/kommu directory as a single git project?

Perhaps you wanted to track just a specific directory?

2 - The .gitignore file usually have to live at the root of the tracked directory.
So make sure it’s at the same level as your .git folder.

Hope this helps :slight_smile:

1 Like

Hello,

Thank you for your reply. I have made a couple of projects since starting using VS code and have then downloaded Git and pushed these to GitHub. I don’t really know where the .git file that was created when I initialized git is located? I know that the .gitconfig is localised on C:/Users/myusername. Should the .git file I am supposted to delete in the C: directory? or should it be in the project folder?

I right-clicked my project folder when I opened it with Git so I thought I was only init and commiting that specifik project. BUT I don’t see a git file in that folder.

I feel that Git is tracking all my files in the C:/users/myusername directory…

delete that gitconfig file
you should have it inside the repository you want to track

1 Like

Hey Marmiz! Thank you so much for the welcome.

Thank you for the guide about how I should think about projects. I have a folder that I call “projects” and in that folder I have as you say I have “projectA” “projectB” and so on. I have no idea how I should add version control to just this folder?

When I downloaded Git and was about to init and push my first project to GitHub I right-clicked not the whole project folder but a single project “projectA”. Then I pushed another project the same way, and so on.

What I can see on my version control in VS code I can see ALL the folders and files in my C:/users/myusername directory. I am trying to figure out where I can find my .git folder? as it is right now I know where the .gitconfig is and this is where I put the .gitignore file.

It feels like there should be a .git file in the projectfolders I have pushed but there isn’t.

Sorry for being all over the place! I am just starting to get the hang of this :slight_smile: :sweat_smile:

Ahh ok… should I have a gitconfig file in every project folder I make?

@AnnikaB, sounds like you initialised your whole user folder as a git dir, rather than each single project.

To fix this, as @ilenia suggested all you have to do is to remove the .git folder, and then initialise them properly.

Mind that .git is a hidden folder (like all other . dot files), so you have to show all hidden files first then remove it.

Finally gitignore should be present on each git project you make.
To give you an idea this is what a project might look like:

c:/my_user/project_a/
    .git
    .gitignore
    node_modules/
    index.js
1 Like

Ah thank you so much, this makes sense! and your example made it all sink in. I will make the changes that you and @ilenia said and see if it solves the problems…

:pray:

Hey guys! (@ilenia)

Thanks so much! it worked! :partying_face:

But just for clarification, should a .gitignore file always be present in a projects .git folder? What is the difference if it is present or not?

.gitingore is used to specify files that you intentionally don’t want to track.

So it’s not mandatory per se, but it’s useful to avoid tracking important files (like secrets and environment variables) as well as redundant files like distribution binaries or dependencies.

You can browse this collections to see some examples:

2 Likes

Another nice resource to help you jump start your .gitignore is gitignore.io.

One other thing to know, is that if add a file or directory you don’t want to track, and you commit that, it will continue to be tracked. At that point, you would need to:

git rm path/to/file --cached

This would remove the file from git tracking, but leave it where it was. You want to be very careful anytime you are removing or deleting files or directories you don’t have backed up, but anytime .gitignore is something new, it’s good to be forewarned, that it only works on files that are not yet tracked or staged for commit. “git status” is your friend, as you always want to check things before you commit, to make sure everything is staged as you expect.

1 Like

Thanks! I will def check it out!

Thanks @gizmola !
I’ve saved your comment and have taken note of it :slight_smile: I will check out the version control in VS code now when I know more about it and only commit the changes that I know are ok!
Thanks for the help!