Configuring git to ignore certain files

I’ve been working with git on and off for about a month now. I’m on a Mac and git always picks up changes to the .DS_Store files within directories. Also when working with XCode, it picks up changes to the user workspace files, etc.

There are a few ways to tell git to ignore these files and not keep them under version control…mainly:

  1. putting a .gitignore file in a directory and listing filenames and/or filename patterns to ignore – this can be checked in just like any other file. The effect is that anyone that clones your directory also will ignore these files.
  2. entering the filenames and/or filename patterns to the .git/info/exclude file in your local repo – only affects your local repo
  3. running the command git config –global core.excludesfile ~/.gitignore_global (.gitignore_global is a file where you specify the ignore patterns) to globally ignore certain files (see the link above fore more details) – I haven’t tried this yet, but this seems great so that you don’t have to re-specify which files to ignore every time you work with a git repo


Leave a Reply