First, remove all of the items from the Git Index (not from the working directory or local repo), and afterward refreshes the Git Index, while respecting git ignores.

git rm -r --cached . 
git add .
git commit -am "Remove ignored files"

Or one-liner:

git rm -r --cached . && git add . && git commit -am "Remove ignored files"
0