blob: 8b42cb3fb20a78cde2eb4c6a7546a334cc71ec4b [file] [log] [blame]
Junio C Hamano36d52292013-01-25 21:32:361git-check-ignore(1)
2===================
3
4NAME
5----
6git-check-ignore - Debug gitignore / exclude files
7
8
9SYNOPSIS
10--------
11[verse]
Junio C Hamanoc9cb5172018-06-01 07:13:4412'git check-ignore' [<options>] <pathname>...
13'git check-ignore' [<options>] --stdin
Junio C Hamano36d52292013-01-25 21:32:3614
15DESCRIPTION
16-----------
17
18For each pathname given via the command-line or from a file via
Junio C Hamano713eded2015-12-03 00:24:0219`--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.
Junio C Hamano36d52292013-01-25 21:32:3622
Junio C Hamano6df93d92014-12-22 22:48:0923By default, tracked files are not shown at all since they are not
24subject to exclude rules; but see `--no-index'.
25
Junio C Hamano36d52292013-01-25 21:32:3626OPTIONS
27-------
28-q, --quiet::
29Don't output anything, just set exit status. This is only
30valid with a single pathname.
31
32-v, --verbose::
33Also output details about the matching pattern (if any)
Junio C Hamano713eded2015-12-03 00:24:0234for each given pathname. For precedence rules within and
35between exclude sources, see linkgit:gitignore[5].
Junio C Hamano36d52292013-01-25 21:32:3636
37--stdin::
Junio C Hamanodaf0aae2015-10-26 23:14:3038Read pathnames from the standard input, one per line,
39instead of from the command-line.
Junio C Hamano36d52292013-01-25 21:32:3640
41-z::
42The output format is modified to be machine-parseable (see
43below). If `--stdin` is also given, input paths are separated
44with a NUL character instead of a linefeed character.
45
Junio C Hamanoc7102962013-05-29 23:57:1746-n, --non-matching::
47Show given paths which don't match any pattern. This only
48makes sense when `--verbose` is enabled, otherwise it would
49not be possible to distinguish between paths which match a
50pattern and those which don't.
51
Junio C Hamano79f4c7c2013-09-20 21:03:3752--no-index::
53Don't look in the index when undertaking the checks. This can
54be used to debug why a path became tracked by e.g. `git add .`
55and was not ignored by the rules as expected by the user or when
56developing patterns including negation to match a path previously
57added with `git add -f`.
58
Junio C Hamano36d52292013-01-25 21:32:3659OUTPUT
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
Junio C Hamano322c6242015-03-23 21:32:4676configured by `core.excludesFile`, or relative to the repository root
Junio C Hamano36d52292013-01-25 21:32:3677when 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
Junio C Hamanoc7102962013-05-29 23:57:1785If `-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.)
94
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.
Junio C Hamano36d52292013-01-25 21:32:3699
100EXIT STATUS
101-----------
102
1030::
104One or more of the provided paths is ignored.
105
1061::
107None of the provided paths are ignored.
108
109128::
110A fatal error was encountered.
111
112SEE ALSO
113--------
114linkgit:gitignore[5]
Junio C Hamano198b1f12016-05-17 22:27:24115linkgit:git-config[1]
Junio C Hamanoa1952302013-07-01 21:31:18116linkgit:git-ls-files[1]
Junio C Hamano36d52292013-01-25 21:32:36117
118GIT
119---
120Part of the linkgit:git[1] suite