When you inherit a code base where gitignore has not been used then the first thing you want to do is add a standard gitignore file like this one Standard Visual Studio gitignore file for example. But the problem is that a bunch of files that match the patterns in that gitignore file have already been added. It is tedious to go through the project and stop tracking the specific files in the various folders like the .vs and debug folders. Is there a git command or a series of git commands that can automate this for us by looking at the gitignore file and stop tracking the files that match the patterns in that gitignore file?
I have searched on Stack Overflow for this and there are some answers but they seem to not rely on the gitignore file to find the files needed to stop tracking.