Try an ignore and an exception
Enter *.log followed by !keep.log. A path named debug.log is ignored while keep.log is included. Rule order matters: a later matching rule can override an earlier one.
Use repository-relative paths
Enter forward-slash paths such as src/app.ts, without a leading slash or ./. Give directories a trailing slash. The matching engine is node-ignore, a JavaScript implementation of Git ignore rules.
Frequently asked questions
Why does a negated path stay ignored?
Git cannot re-include a file when a parent directory is excluded. Re-include the parent directory before negating the file, or change the directory rule to exclude its contents instead.
Does this inspect my Git repository?
No. This applies one root .gitignore rule list to paths you supply. It does not inspect tracked files, the Git index, global excludes, .git/info/exclude or nested .gitignore files. Use git check-ignore in your repository for the final result.