Searching through my own blog to see if I made a note about this, but I didn't. Luckily I found it again.

If you want to ignore something in Git, the best known way is to put the filename in a file called .gitignore. This approach has the benefit that it can be committed, therefore shared with others. But sometimes you have files only you have, because you are using some obscure tool or editor – Vim, in my case. Those files are better ignored in your ~/.gitignore_global, so that Git ignores them in all your projects. I store mine in my dotfiles by adding the following to my ~/.gitconfig file:

[core]
    excludesfile = ~/dotfiles/git/gitignore_global

But then, sometimes you want to ignore something that's very specific to this project. In that case, you can open a file inside the .git folder of your project, and put it in there: .git/info/exclude. Usually it's already there with some comments in it on how to use it. Just be careful: the .git folder is your local git repository, so don't go messing around with the other files unless you know what you are doing or have good backups.