git .gitignore not working

If we come across a situation when we feels that the .gitignore file is not working then you are required to run these below commands-

git rm -rf --cached .

This removes any changed files from the staging area, then run the below command-

git add .

After running these above commands, now run the commit command and see the effect.

git commit -m "now my gitignore file works"