Global .gitignore

I freaking hate DS.Store files. I had to add them to every project's .gitignore. Today I got sick of it and did some research (read: "spent 5 seconds googling").

Turns out, it is possible to have a global gitignore file.

Step 1

Create the file somewhere (it doesn't matter). I put mine into ~/.gitignore-global.

Step 2

Run git config --global core.excludesfile ~/.gitignore-global

Step 3

Add some common exclusions there. Check out a big list of those on Github:help.

One note on the list: I personally don't feel like putting *.log into .gitignore-global. Sometimes you will actually need .log files in your repo.

What you won't need, however, are these freaking DS.Store files. Them and their brothers from other operating systems. So it's safe to ignore them globally.

As a result, I ended up with this .gitignore-global:

.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

Step 4

That's it, you are set for life.

You're the 10486th person to read this article.