Steven Wake

Global Git ignore

A handy little feature of Git is the global ignore file. Use this file to exclude annoying system files from your nice clean repo, especially good for those dreaded .DS_Store files (Mac poo) on OSX and Thumbs.db files on Windows.

Setup and configuration of a global ignore file is extremely simple:

1. Create a text file somewhere on your system. I would recommend your home directory. Name the file whatever you choose. As a configuration file I would recommend starting the file name with a “.” in order to hide it. I named my file “.gitignore_global”

2. Populate your file with patterns you wish to ignore in your repos. You probably want to start with the following 2 main offenders:

Thumbs.db
*.DS_Store

I develop Cocoa apps using Xcode so I added the following as well:

*.xcuserstate
project.xcworkspace/
xcuserdata/

3. Fire off the following command at the terminal, replacing the path at the end for the path to the your ignore file:

git config —global core.excludesfile ~/.gitignore_global

That was easy wasn’t it!

Two final tips to consider when using a global ignore:

1. Ignore files do not remove files that match your patterns. If you add a pattern after the fact, you will need to use Git rm to remove them.

2. Tread carefully. Being too heavy handed with a global ignore file may lead to head scratching and wasted debugging effort

Tags: git

Comments: 1

Gareth
commented on

Remember if you're sharing your project with any other users (as is common with git repositories) that a global gitignore file is specific to your system. It won't stop any other users from adding those files into your repository. If you really need those files never to be committed then you'll need a project .gitignore file too

Add a comment

Note: comments are moderated before publication.

Most Popular

Website easter egg

Piers Palmer

We decided to have a little fun now that summer is over, combining some design yumminess and behavioural goodness. See if you are up to the challenge! Can you find the indomitable and mighty web geek PROFESSOR WAKE on our website. He’s hiding there somewhere… A littl…

Easy image rollovers

Robin Whittleton

Recently themeforest.net ran a quick tutorial on how to achieve an image slide effect similar to our homepage. I thought I’d go into some more detail about the design decisions we made.

Kyan Jukebox Festive 50 2008

Gavin Shinfield

Alright pop pickers? Not ’arf! Well, it’s that time of year again, best of 2008 lists abound so I thought I’d put together some of the top tracks to be rocking the Kyan jukebox from this year’s releases and now that Saint John no longer graces our airwave…