I found myself contributing to an open source project recently … here & here. First thing that I thought awkward was that the project’s .gitignore file paid no attention to OS- generated or editor-generated files. So I happily contributed those exclusions to the project’s .gitignore so we ended up with this

# Editor Files #

# OS generated files #

Which isn’t elegant. At all.

I have a slight problem with this, though. The .DS_Store isn’t related to your project, it is related to the system you’re coding on. Your .gitignore file will be a lot more elegant if it only lists files that are related to the projects.


Git has a global configuration that applies rules to all of your projects.

On linux for example:

$ git config --global core.excludesfile ~/.global_ignore

On Windows (if using GitHub. for Windows) the .gitconfig file lives in the user’s home directory. In my case, for example ( & on Windows Vista/8), the location of the .gitconfig file is C:\Users\YOU\.gitconfig. To set up a global gitconfig, I use a directory C:\Users\YOU\config\ containing a file called global_ignore, and in .gitconfig I would add;

    name = King'ori Maina
    email = [email protected]

    excludesfile = C:/Users/itskingori/configs/global_ignore

And finally in the global_ignore file we have something like;

## Editor Files ##

## Backup ##

## Logs and databases ##

## Packages ##
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods

# OS generated files #

Of course this is my pref, feel free to use whatever suits you.

  1. A collection of useful .gitignore Templates
  2. Ignoring files
  3. Setting up a global .gitignore for Github for Windows
  4. Global gitignores