Remove previously tracked files listed in newly added .gitignore

To remove files one by one use:

git rm --cached 

Or to remove all files listed on your .gitignore file:

git ls-files -i --exclude-from=.gitignore | xargs git rm --cached