Pure Danger Tech


navigation
home

git ignore files

17 May 2008

I started playing with git a bit for a personal repository. Installing it on the Mac was trivial thanks to the git OS X installer. From download page to a working repository was probably less than 5 minutes.

Since I’m most familiar with Subversion, I’m finding the Git – SVN Crash Course very helpful. The Git tutorial is also very helpful.

One of the first issues I ran into was wanting to ignore the common .DS_Store file which shows up in Mac directories. The basics on where ignores are picked up is covered fairly well in the man pages and boils down to looking at:

  • command-line args (where appropriate)
  • .gitignore file in the git repository directories
  • $GIT_DIR/info/exclude
  • a file specified by the core.excludes property

Which one you want to use depends on how widely you want this setting to be shared. If other users will necessarily need this as part of their repository, then it should be in .gitignore so they get it with their repo. Ignores that are specific to one user’s workflow should go in the exclude file and files that should always be ignored should be stored in the last option. As far as I can tell, I want the last one.

One question I had was what $GIT_DIR was. I did find a file like this at /usr/local/git/share/git-core/templates/info/exclude but setting patterns there seemed to have no effect.

Instead I ended up putting this in a file specified by the core.excludes property. The properties are stored at ~/.gitconfig and you can either modify it directly or use some of the git commands. I needed to set the “core.excludesfile” property. It took me a while to understand that “core” is the section and “excludesfile” is the property so the relevant portion of the config file looks like this:

[core]
        excludesfile = "/path/to/.gitexcludes"

and the .gitexcludes file just contains the pattern “.DS_Store”.

Hope that helps someone in the future…