Git & Version Control · Cheatsheet
Gitignore Patterns Cheatsheet
Check .gitignore patterns, directory scope, exceptions, and tracked-file limits. Diagnose matching rules with Git check-ignore examples.
40 commands 7 sections
No entry matches that filter.
-
Untracked files onlyIgnore rules do not remove files already tracked by Git -
Ignore is not access controlAn ignore rule does not protect or encrypt a file -
Last matching ruleWithin one rule level, the last matching pattern decides -
Pattern examples are separateCombine only the examples that match your intended policy
-
*.logMatch log names at any depth below this ignore file -
debug.logMatch this file or directory name at any depth -
/debug.logMatch this name only beside the ignore file -
*.tmpMatch names with a temporary-file extension -
report?.csvMatch report plus one non-slash character, then .csv -
report[0-9].csvMatch report plus one digit, then .csv
-
cache/Ignore directories named cache at any depth below this file -
/cache/Ignore only the cache directory beside this ignore file -
build/output.txtMatch this path relative to the ignore file -
docs/*.htmlMatch direct HTML children of docs -
docs/**/*.htmlMatch HTML files inside docs at any depth -
**/temp/Ignore directories named temp at any depth
-
*.log !important.logKeep important.log eligible when no parent is excluded -
/build/* !/build/keep.txtIgnore build children except keep.txt -
/cache/ !/cache/keep.txtThis exception fails because its parent remains excluded -
# CommentAdd a comment on its own line -
\#notes.txtMatch a name that starts with a literal hash -
\!important.txtMatch a name that starts with a literal exclamation mark
-
git check-ignore -v -- <file>Show a matching rule; ! marks an inclusion exception -
git check-ignore --no-index -v -- <file>Check rule matching even when the file is tracked -
git check-ignore -q -- <file>Return 0 for ignored, 1 for not ignored, or 128 on error -
git status --short --ignoredShow ignored paths with !! markers -
git ls-files -- <file>Check whether this path is already tracked -
git ls-files --others --ignored --exclude-standardList ignored untracked files using standard rule sources
-
.gitignoreCommit shared rules that apply to the project -
.git/info/excludeKeep rules for this local repository only -
core.excludesFileConfigure a separate ignore file for personal patterns -
Nested .gitignoreApply a rule to its directory and descendants -
Already tracked filePlan an index change separately; ignoring alone has no effect -
Exposed private dataIgnoring later does not remove data from earlier commits