Git .gitignore not working

If .gitignore is not working you need to remove cached files using the command below

git rm -r --cached .