Kejia Cui
Kejia Cui

Reputation: 111

VS code: Is there a way to ignore files in git?

I am using VS code with git. There are a lot of files(4G+) in the repos and I don't care about most of them. But they are needed during compile. So when I create the VS code workspace, I only added the folder/files I am interested. Then I found the source control in VS code listed 5K files and complained they are modified but actually not. I think the reason is these files are tracked by git but I didn't add them to my workspace. Is there a way to ignore such files?

.gitignore doesn't work for this because all the files are not local, they are all tracked by git. I don't want to add them all to the VS code workspace since I only care about part of them.

Thanks in advance!

Upvotes: 2

Views: 8401

Answers (1)

Psychotechnopath
Psychotechnopath

Reputation: 2744

If you want to untrack files that have already been added to a (cloned) git repository (I think that is what you mean), you can use git rm --cached filename

You can also tell git you want your own independent version of the file or folder. For instance, you don't want to overwrite (or delete) production/staging config files. The way to do this is by using git update-index --skip-worktree <path-name>.

For a more elaborate discussion on this topic please check our This question and This link

Upvotes: 3

Related Questions