Skip to content

Commit

Permalink
gitignore.txt: clarify recursive nature of excluded directories
Browse files Browse the repository at this point in the history
Additionally, precedence of negated patterns is exactly as outlined in
the DESCRIPTION section, we don't need to repeat this.

Signed-off-by: Karsten Blees <blees@dcon.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Karsten Blees authored and Junio C Hamano committed Dec 9, 2013
1 parent 8447dc8 commit 59856de
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Documentation/gitignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ PATTERN FORMAT

- An optional prefix "`!`" which negates the pattern; any
matching file excluded by a previous pattern will become
included again. If a negated pattern matches, this will
override lower precedence patterns sources.
included again. It is not possible to re-include a file if a parent
directory of that file is excluded. Git doesn't list excluded
directories for performance reasons, so any patterns on contained
files have no effect, no matter where they are defined.
Put a backslash ("`\`") in front of the first "`!`" for patterns
that begin with a literal "`!`", for example, "`\!important!.txt`".

Expand Down Expand Up @@ -182,6 +184,19 @@ Another example:
The second .gitignore prevents Git from ignoring
`arch/foo/kernel/vmlinux.lds.S`.

Example to exclude everything except a specific directory `foo/bar`
(note the `/*` - without the slash, the wildcard would also exclude
everything within `foo/bar`):

--------------------------------------------------------------
$ cat .gitignore
# exclude everything except directory foo/bar
/*
!/foo
/foo/*
!/foo/bar
--------------------------------------------------------------

SEE ALSO
--------
linkgit:git-rm[1],
Expand Down

0 comments on commit 59856de

Please sign in to comment.