why gitignore does not work

C++
git rm -rf --cached .
git add .

Source

Also in C++: