Git starts tracking repository files and respecting the patterns set in the .gitignore file after you run the git add command.
If you later set in the .gitignore file, you want Git to start tracking a file you previously selected to be ignored.
Use these commands to refresh the git cache and apply the .gitignore changes.
git rm -r --cached .
git add .