6 gitignore - Specifies intentionally untracked files to ignore
10 $GIT_DIR/info/exclude, .gitignore
15 A `gitignore` file specifies intentionally untracked files that
16 git should ignore. Each line in a `gitignore` file specifies a
19 When deciding whether to ignore a path, git normally checks
20 `gitignore` patterns from multiple sources, with the following
23 * Patterns read from the file specified by the configuration
24 variable 'core.excludesfile'.
26 * Patterns read from `$GIT_DIR/info/exclude`.
28 * Patterns read from a `.gitignore` file in the same directory
29 as the path, or in any parent directory, ordered from the
30 deepest such file to a file in the root of the repository.
31 These patterns match relative to the location of the
32 `.gitignore` file. A project normally includes such
33 `.gitignore` files in its repository, containing patterns for
34 files generated as part of the project build.
36 The underlying git plumbing tools, such as
37 gitlink:git-ls-files[1] and gitlink:git-read-tree[1], read
38 `gitignore` patterns specified by command-line options, or from
39 files specified by command-line options. Higher-level git
40 tools, such as gitlink:git-status[1] and gitlink:git-add[1],
41 use patterns from the sources specified above.
43 Patterns have the following format:
45 - A blank line matches no files, so it can serve as a separator
48 - A line starting with # serves as a comment.
50 - An optional prefix '!' which negates the pattern; any
51 matching file excluded by a previous pattern will become
54 - If the pattern does not contain a slash '/', git treats it as
55 a shell glob pattern and checks for a match against the
56 pathname without leading directories.
58 - Otherwise, git treats the pattern as a shell glob suitable
59 for consumption by fnmatch(3) with the FNM_PATHNAME flag:
60 wildcards in the pattern will not match a / in the pathname.
61 For example, "Documentation/\*.html" matches
62 "Documentation/git.html" but not
63 "Documentation/ppc/ppc.html". A leading slash matches the
64 beginning of the pathname; for example, "/*.c" matches
65 "cat-file.c" but not "mozilla-sha1/sha1.c".
69 --------------------------------------------------------------
74 # Documentation/foo.html
75 # Documentation/gitignore.html
80 $ cat .git/info/exclude
81 # ignore objects and archives, anywhere in the tree.
83 $ cat Documentation/.gitignore
84 # ignore generated html files,
86 # except foo.html which is maintained by hand
92 # Documentation/foo.html
94 --------------------------------------------------------------
98 --------------------------------------------------------------
101 $ ls arch/foo/kernel/vm*
102 arch/foo/kernel/vmlinux.lds.S
103 $ echo '!/vmlinux*' >arch/foo/kernel/.gitignore
104 --------------------------------------------------------------
106 The second .gitignore prevents git from ignoring
107 `arch/foo/kernel/vmlinux.lds.S`.
111 Documentation by David Greaves, Junio C Hamano, Josh Triplett,
112 Frank Lichtenheld, and the git-list <git@vger.kernel.org>.
116 Part of the gitlink:git[7] suite