After adding .gitignore file use following commands
git rm -r --cached .
git commit -m ".gitignore is now working"
Make sure to commit first your changes you want to keep. The –cached option will keep your files untouched on your disk though. Other more solution: git rm --cached `git ls-files -i --exclude-standard` Files with space in their paths In case you get an error message like fatal: path spec ‘…’ did not […]