apply gitignore to current commit

C++
#First commit all changes
git rm -r --cached .
git add .
git commit -m ".gitignore updated"
Source

Also in C++: