GIT-CHECK-IGNORE(1)
π git-check-ignore(1) π
okay bestie, welcome to the git-check-ignore page β it's the git manual's very own detective for gitignore / exclude files, and honestly? iconic. π΅οΈββοΈβ¨
β¨ SYNOPSIS β¨
git check-ignore [<options>] <pathname>...
git check-ignore [<options>] --stdin
π DESCRIPTION π
so here's the vibe: for every single pathname you hand over β either straight on the command line, or from a file via --stdin β it checks whether that file is excluded by .gitignore (or whatever other input files feed into the exclude mechanism), and if it is excluded, it prints the path out. simple as that. π
and by default, tracked files justβ¦ don't show up at all πΈ β because they're not subject to exclude rules, periodt. but hey, see --no-index if you wanna change that story.
π OPTIONS π
-q,--quietβ don't output anything babes, just set the exit status. β οΈ this one's only valid with a single pathname, no cap.-v,--verboseβ instead of printing just the paths that are excluded, for each path that matches an exclude pattern it prints the exclude pattern together with the path. (heads up: matching an exclude pattern usually means the path is excluded, but if the pattern begins with"!"then it's a negated pattern β and matching that means the path is NOT excluded. plot twist π)
for the precedence rules within and between exclude sources, go peek at gitignore(5).
--stdinβ read pathnames from standard input, one per line, instead of from the command-line. v chill of it. π«Ά-zβ modifies the output format to be machine-parsable (see below π). and if--stdinis also given, input paths get separated with a NUL character instead of a linefeed character.-n,--non-matchingβ show given paths which don't match any pattern. β οΈ this only makes sense when--verboseis enabled, otherwise you literally couldn't distinguish between paths that match a pattern and paths that don't. it's giving logic.--no-indexβ don't look in the index when undertaking the checks. this is your debug bestie π for figuring out why a path became tracked by e.g.git add .and wasn't ignored by the rules the way you expected β or for when you're developing patterns (including negation) to match a path previously added withgit add -f.
π¦ OUTPUT π¦
by default, any of the given pathnames which match an ignore pattern get output, one per line. and if no pattern matches a given path? nothing gets output for that path β which means that path will not be ignored. π
if --verbose is specified, the output is a series of lines of the form:
<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
so: <pathname> is the path of a file being queried, <pattern> is the matching pattern, <source> is the pattern's source file, and <linenum> is the line number of the pattern within that source. and if the pattern contained a "!" prefix or "/" suffix, it will be preserved in the output β¨. <source> will be an absolute path when referring to the file configured by core.excludesFile, or relative to the repository root when referring to .git/info/exclude or a per-directory exclude file. iykyk π
if -z is specified, the pathnames in the output are delimited by the null character; and if --verbose is also specified then null characters are also used instead of colons and hard tabs:
<source> <NULL> <linenum> <NULL> <pattern> <NULL> <pathname> <NULL>
if -n or --non-matching are specified, non-matching pathnames will also be output, in which case all fields in each output record except for <pathname> will be empty. this is lowkey so useful when running non-interactively β files can be incrementally streamed to STDIN of a long-running check-ignore process, and for each of these files, STDOUT will indicate whether that file matched a pattern or not. (without this option, it would be impossible to tell whether the absence of output for a given file meant that it didn't match any pattern, or that the output hadn't been generated yet.) π₯
buffering happens as documented under the GIT_FLUSH option in git(1). β οΈ and the caller is responsible for avoiding deadlocks caused by overfilling an input buffer or reading from an empty output buffer. don't do that to yourself bestie π
β EXIT STATUS β
0β one or more of the provided paths is ignored. slay π1β none of the provided paths are ignored. π128β a fatal error was encountered. π
πΈ SEE ALSO πΈ
gitignore(5) git-config(1) git-ls-files(1)
π GIT π
part of the git(1) suite π«Ά
and that's the whole page bestie β Git 2.56.0, dated 2026-09-27, no cap. go forth and check-ignore your heart out πβ¨π
π¦ where this page comes from
- arch rolling: git 2.56.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms