On 2009-02-24, Junio C Hamano <gitster@xxxxxxxxx> wrote: > I think you are looking for "/foo/". From Documentation/gitignore.txt: [lots of very clear and detailed explanation snipped for brevity...] I'd been sort of struggling with the part of 'man gitignore' that describes the rules for the exclusion patterns; it just didn't seem as clear as it could have been. It's very accurate, but I (and I noticed a few others on irc) had to read very carefully to do anything moderately complex. A few days ago, 'doener' (Björn Steinbrink) came up with some much simpler rules that said the same thing, and -- building on the insight that his rules gave me -- I came up with these: ----->8----- Note that rule 1 merely *modifies* rules 2 and 3, it does not supercede or preclude them. 1. If you pattern ends with a slash, it matches only directories (and their contents) 2. If there is no slash otherwise, it matches that name, at any depth in the tree 3. If there is a slash anywhere else, it matches that name, relative to the .gitignore (or $GIT_WORK_TREE if the pattern is from one of the other pattern sources like `.git/info/exclude` etc) The wildcards (`*` and `?`) do not match slashes, but otherwise the patterns are normal shell globs as defined by fnmatch(3) with the FNM_PATHNAME flag set. ----->8----- Those rules are meant to clarify the following lines from the gitignore man page: - 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). - If the pattern does not contain a slash '/', git treats it as a shell glob pattern and checks for a match against the pathname without leading directories. - Otherwise, git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html