LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-check-ignore

Debug gitignore patterns and ignored files

TLDR

Check if file is ignored
$ git check-ignore [file.txt]
copy
Show matching rule
$ git check-ignore -v [file.txt]
copy
Check multiple files
$ git check-ignore [file1.txt] [file2.txt]
copy
Read paths from stdin
$ echo "[path]" | git check-ignore --stdin
copy
Check all ignored files
$ git check-ignore *
copy

SYNOPSIS

git check-ignore [options] pathspec

DESCRIPTION

git check-ignore debugs gitignore patterns. It reports whether paths are ignored and which pattern causes the ignore, helping troubleshoot gitignore rules.The verbose mode (-v) shows the gitignore file, line number, and pattern responsible for ignoring a path. This is essential for debugging complex gitignore configurations with multiple .gitignore files at different directory levels.The --non-matching option combined with -v can also show why a file is not being ignored, helping diagnose cases where files unexpectedly appear in git status output.

PARAMETERS

PATHSPEC

File paths to check.
-v, --verbose
Show source and pattern.
--stdin
Read paths from stdin.
-z
NUL-terminate output.
-n, --non-matching
Show non-matching paths.
-q, --quiet
Exit with status only.
--help
Display help information.

CONFIGURATION

.gitignore

Pattern list specifying intentionally untracked files to ignore. Multiple .gitignore files can exist at different directory levels.
~/.config/git/ignore
User-level global ignore patterns applied to all repositories.
/etc/gitconfig
System-wide core.excludesFile configuration pointing to global ignore file.

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

CAVEATS

Only checks patterns, not actual files. Nested gitignore files have priority. Negation patterns can override ignores.

HISTORY

git check-ignore was added to Git to help debug gitignore rules, addressing common frustration with ignore pattern behavior.

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid