To stop keeping track of a single file that has already been added or initialized to your repository, use the following command:
git rm --cached filename
Note: This command will stop tracking the file but not delete it from your system.
But if you want to ignore every file that is now in your .gitignore follow the steps given below:
Step 1: Commit any outstanding code changes
Step 2: Then run the following command which will remove any changed files from the staging area
git rm -r --cached .
Step 3: Then run the following command:
git add .
Step 4: Now commit it with the following command:
git commit -m ".gitignore is now working"
For more information please go through the following tutorial to get more info about git: