set global git ignore

C++
touch ~/.gitignore
git config --global core.excludesfile ~./gitignore
Source

Also in C++: