Ignoring directories with Git.

Ignoring directories in git was a concept hard for me to grasp. The gitignore help file didn’t help me all that much.

If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git).

This never worked for me. The only way I could get it to work was to use something like “directory/*” in my .gitignore file. I could also just use “directory”, but that would match any file and directory with that name. It would also look for other matches further down the tree recursively.

So in summary to hide the build directory use:

build/*

This entry was posted on Tuesday, January 27th, 2009 at 9:56 pm and is filed under Git. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply