@matheusbsbs / matheus-bagliano / commits / 81c13fde37
Fork 0

gitignore.5: Clarify matching rules

Patterns containing a / are implicitly anchored to the directory containing the relevant .gitignore file. Patterns not containing a / are textual matches against the path name relative to the directory containing .gitignore. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Mar 5, 2010 at 09:56 UTC 81c13fde379c46cad6b6e4a03ed7ee4f686c030f
1 file changed +9 -5
Documentation/gitignore.txt
+9 -5
@@ -83,16 +83,20 @@ Patterns have the following format:
83
84 - If the pattern does not contain a slash '/', git treats it as
85 a shell glob pattern and checks for a match against the
86 - pathname without leading directories.
86 + pathname relative to the location of the `.gitignore` file
87 + (relative to the toplevel of the work tree if not from a
88 + `.gitignore` file).
89
90 - Otherwise, git treats the pattern as a shell glob suitable
91 for consumption by fnmatch(3) with the FNM_PATHNAME flag:
92 wildcards in the pattern will not match a / in the pathname.
93 For example, "Documentation/\*.html" matches
92 - "Documentation/git.html" but not
93 - "Documentation/ppc/ppc.html". A leading slash matches the
94 - beginning of the pathname; for example, "/*.c" matches
95 - "cat-file.c" but not "mozilla-sha1/sha1.c".
94 + "Documentation/git.html" but not "Documentation/ppc/ppc.html"
95 + or "tools/perf/Documentation/perf.html".
96 +
97 + - A leading slash matches the beginning of the pathname.
98 + For example, "/*.c" matches "cat-file.c" but not
99 + "mozilla-sha1/sha1.c".
100
101 An example:
102