git update gitignore

C++
# rm all files
git rm -r --cached .
# add all files as per new .gitignore
git add .
# now, commit for new .gitignore to apply
git commit -m ".gitignore is now working"
git rm -r --cached .
git rm -r --cached .
git add .
git commit -m "update gitignore"$ touch .gitignoregit ls-files --ignored --exclude-standard -z | xargs -0 git rm --cached
git commit -am "Remove ignored files"


// answer from: thSoft
Source

Also in C++: