# First solution
$ git rm -r --cached . # We remove
$ git add . # We stage
$ git commit -m "Clean up ignored files" # We commit
# Second solution : if you have a lot of files
# It's basicaly the first solution in one line
git rm --cached `git ls-files -i -c --exclude-from=.gitignore`
# If you are on Windows and the line above didn't work, try this one in Powershell
git ls-files -i -c --exclude-from=.gitignore | %{git rm --cached $_}
git ls-files -i --exclude-from=.gitignore | %{git rm --cached $_}
// works with windows powershell
git ls-files -i -z --exclude-from=.gitignore | xargs -0 git rm --cached
git ls-files --ignored --exclude-standard -z | xargs -0 git rm --cached
git commit -am "Remove ignored files"
// answer from: thSoft
git rm -r --cached .
git add .
git commit -am "Drop ignored files"