.gitignore Pattern Tester
Test whether a specific file path is ignored or tracked by Git using the syntax rules from your .gitignore file. This tool evaluates your glob patterns against candidate paths locally in your browser, helping you debug why certain files are unexpectedly appearing in git status or failing to be ignored.
Inputs and Outputs
- Input: Your
.gitignorerules (pasted text or loaded from a local file) and a list of file paths you want to check. - ** A clear verdict for each path: Ignored or Tracked**.
How It Works
The tool applies standard Git glob matching logic (similar to fnmatch) to your patterns. It does not connect to your repository; it simply simulates the rule engine based on the text you provide. If a rule matches a parent directory, the tool reflects that the contents inside will not be re-evaluated for negation, which is a common source of confusion.
Why Your Patterns May Not Behave as Expected
Negation Rules and Directory Exclusion
You cannot un-ignore a file if its parent directory is already excluded. For example, if you have logs/ in your .gitignore, adding !logs/error.log will not work because Git never looks inside logs/ to find the negation pattern. You must remove the parent directory exclusion or use a more specific file pattern to allow exceptions.
Pattern Scope
- Root patterns: Patterns without a leading slash (e.g.,
*.log) match files at any depth. - Rooted patterns: Patterns with a leading slash (e.g.,
/tmp) match only from the root of the repository. - Trailing slashes: A trailing slash (e.g.,
dist/) matches directories only, not files.
Order Matters
The last matching rule wins. If you ignore *.js but then add !src/main.js, the file will be tracked. However, if you ignore src/ later, the exception is voided. Use this tool to verify the final state of your rule stack.
Practical Use Cases
- Debugging
git status: You added a.envfile, but it’s still showing up. Test your!.envexception against the*.envignore rule to see if the negation is actually applying. - Pre-commit Cleanup: Before committing a new dependency folder, test whether
node_modules/is correctly excluding all subdirectories. - Documentation: Provide a clear list of what is ignored for onboarding new developers, generated directly from your tested rules.
Limitations and Privacy
Not a Repository Scanner
This tool does not read your actual .git directory or check which files are currently tracked by Git. A file that is already tracked in your repository will remain tracked even if you add an ignore pattern for it. You must use git rm --cached to untrack existing files; the .gitignore file only affects new or untracked files.
Browser-Local Processing
Your patterns and file paths are processed entirely within your browser. No data is sent to a server. This means you can safely test sensitive path names without uploading your code, but you must ensure your browser supports the necessary JavaScript features for glob matching.
Important: browser parsers cover common practical cases. Always review generated files before using them in production, especially for configuration, subtitles, images and security-sensitive data.