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