]> git.ipfire.org Git - thirdparty/git.git/blame_incremental - Documentation/git-check-ignore.txt
Merge branch 'tb/ci-run-cocci-with-18.04' into maint
[thirdparty/git.git] / Documentation / git-check-ignore.txt
... / ...
CommitLineData
1git-check-ignore(1)
2===================
3
4NAME
5----
6git-check-ignore - Debug gitignore / exclude files
7
8
9SYNOPSIS
10--------
11[verse]
12'git check-ignore' [<options>] <pathname>...
13'git check-ignore' [<options>] --stdin
14
15DESCRIPTION
16-----------
17
18For each pathname given via the command-line or from a file via
19`--stdin`, check whether the file is excluded by .gitignore (or other
20input files to the exclude mechanism) and output the path if it is
21excluded.
22
23By default, tracked files are not shown at all since they are not
24subject to exclude rules; but see `--no-index'.
25
26OPTIONS
27-------
28-q, --quiet::
29 Don't output anything, just set exit status. This is only
30 valid with a single pathname.
31
32-v, --verbose::
33 Instead of printing the paths that are excluded, for each path
34 that matches an exclude pattern, print the exclude pattern
35 together with the path. (Matching an exclude pattern usually
36 means the path is excluded, but if the pattern begins with '!'
37 then it is a negated pattern and matching it means the path is
38 NOT excluded.)
39+
40For precedence rules within and between exclude sources, see
41linkgit:gitignore[5].
42
43--stdin::
44 Read pathnames from the standard input, one per line,
45 instead of from the command-line.
46
47-z::
48 The output format is modified to be machine-parsable (see
49 below). If `--stdin` is also given, input paths are separated
50 with a NUL character instead of a linefeed character.
51
52-n, --non-matching::
53 Show given paths which don't match any pattern. This only
54 makes sense when `--verbose` is enabled, otherwise it would
55 not be possible to distinguish between paths which match a
56 pattern and those which don't.
57
58--no-index::
59 Don't look in the index when undertaking the checks. This can
60 be used to debug why a path became tracked by e.g. `git add .`
61 and was not ignored by the rules as expected by the user or when
62 developing patterns including negation to match a path previously
63 added with `git add -f`.
64
65OUTPUT
66------
67
68By default, any of the given pathnames which match an ignore pattern
69will be output, one per line. If no pattern matches a given path,
70nothing will be output for that path; this means that path will not be
71ignored.
72
73If `--verbose` is specified, the output is a series of lines of the form:
74
75<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
76
77<pathname> is the path of a file being queried, <pattern> is the
78matching pattern, <source> is the pattern's source file, and <linenum>
79is the line number of the pattern within that source. If the pattern
80contained a `!` prefix or `/` suffix, it will be preserved in the
81output. <source> will be an absolute path when referring to the file
82configured by `core.excludesFile`, or relative to the repository root
83when referring to `.git/info/exclude` or a per-directory exclude file.
84
85If `-z` is specified, the pathnames in the output are delimited by the
86null character; if `--verbose` is also specified then null characters
87are also used instead of colons and hard tabs:
88
89<source> <NULL> <linenum> <NULL> <pattern> <NULL> <pathname> <NULL>
90
91If `-n` or `--non-matching` are specified, non-matching pathnames will
92also be output, in which case all fields in each output record except
93for <pathname> will be empty. This can be useful when running
94non-interactively, so that files can be incrementally streamed to
95STDIN of a long-running check-ignore process, and for each of these
96files, STDOUT will indicate whether that file matched a pattern or
97not. (Without this option, it would be impossible to tell whether the
98absence of output for a given file meant that it didn't match any
99pattern, or that the output hadn't been generated yet.)
100
101Buffering happens as documented under the `GIT_FLUSH` option in
102linkgit:git[1]. The caller is responsible for avoiding deadlocks
103caused by overfilling an input buffer or reading from an empty output
104buffer.
105
106EXIT STATUS
107-----------
108
1090::
110 One or more of the provided paths is ignored.
111
1121::
113 None of the provided paths are ignored.
114
115128::
116 A fatal error was encountered.
117
118SEE ALSO
119--------
120linkgit:gitignore[5]
121linkgit:git-config[1]
122linkgit:git-ls-files[1]
123
124GIT
125---
126Part of the linkgit:git[1] suite