.gitignore Reference
Browse .gitignore syntax patterns and copy pre-built templates for popular languages and tools.
filename.txtbasicIgnore a specific file in any directory
e.g. secret.txt, .env
/filename.txtbasicIgnore only in the root directory (leading slash)
e.g. /TODO
# commentbasicComment line — ignored by Git
e.g. # Build artifacts
(blank line)basicBlank lines are ignored
*.logwildcardIgnore all files with .log extension
e.g. *.tmp, *.bak
*.{js,ts}wildcardIgnore multiple extensions (brace expansion — not standard, use two lines)
e.g. *.js *.ts (safer)
**/*.logwildcardIgnore .log files in all subdirectories
e.g. **/dist/**
file?wildcard? matches exactly one character
e.g. file? matches file1, fileA
file[0-9]wildcard[ ] matches a character range
e.g. file[abc] matches filea, fileb
build/*wildcardIgnore all files inside build/ but not build/ itself
e.g. dist/*
!important.lognegationUn-ignore a previously ignored file (negation)
e.g. !.env.example
!vendor/important/negationRe-include a directory excluded by a parent rule
e.g. !src/lib/keep/
node_modules/directoryIgnore the directory and its contents (trailing slash = directory only)
e.g. .next/, dist/
logs/directoryIgnore any directory named 'logs' anywhere in the tree
e.g. tmp/, cache/
build/directoryIgnore build output directories
e.g. out/, .output/
doc/**/*.txtadvancedIgnore all .txt files in doc/ and all its subdirectories
e.g. src/**/*.test.js
*/tempadvancedIgnore any 'temp' file or dir exactly one level deep
e.g. */debug
\#file.txtadvancedEscape # to treat it as a literal character
e.g. \!literal.txt