gitvisual-studio-codegitignoregit-rm

Easily remove multiple tracked files and add them to gitignore with VSCode


I have a folder with many files tracked by git, and I would like to untrack many of theses files in a simple way.

Usually when I compile my solution, I see from VSCode source control tab some tracked files that shouldn't be. It's easy to select them all and add them to .gitignore file with the right click, but I can't find any option to untrack them all in an easy way (right click style).

Otherwise I have to do:

git rm --cached <file>

for each files, which is a pain when I have many file to untrack. Thanks.


Solution

  • git rm --cached . 
    git add . 
    

    The . stands for your current working directory. Since you specify the entire directory git will recursively go through and remove all tracked files.

    Adding all files back will add everything except for the gitignored files.