[NOTE]
This does not remove the files from history or previous commits to the repository like GitHub.
For the files already committed to a remote git repository, you’ll need to unstage them, create a new commit and push to your remote git repository.
[Windows, Linux & Mac]
git rm -r --cached .
git add -A
git status
git commit -am 'Removing ignored files'
git rm -r --cached . && git add -A && git status && git commit -am 'Removing ignored files'
git-update-index (alternative)
Tell git to avoid writing the file to the working directory when reasonably possible, and treat the file as unchanged when it is not present in the working directory.
Note: that not all git commands will pay attention to this bit, and some only partially support it.
Source: SKIP-WORKTREE BIT
[Windows, Linux & Mac] To
git update-index --skip-worktree <file>
[Windows, Linux & Mac] To Cancel/stop
git update-index --no-skip-worktree <file>
[Linux & Mac]
xargs - or get windows alternative/WSL to this.
git ls-files -z --ignored --exclude-standard | xargs -0 git rm -r --cached
git commit -am "Removing ignored files"