If you are like me and love using a Mac for your development tasks, and want a way to get Git to ignore any file (like those pesky .ds_store’s) forever and for EVERY repository there is a very simple way to it.
Open Terminal and type:
git config --global core.excludesfile ~/.gitignore
echo .DS_Store >> ~/.gitignore
This will work for anything you want, just modify the second command as appropriate. And you can run the second command as many times as you need.