Generate .gitignore
Select your languages, frameworks, IDEs, and operating systems to generate a comprehensive .gitignore file. All patterns are based on community best practices.
Languages
Frameworks
IDEs & Editors
Operating Systems
Build Tools & Others
Common Presets
Generated .gitignore
How .gitignore Works
A .gitignore file tells Git which files and directories to exclude from version control. It uses pattern matching to identify files that should never be committed to your repository.
Pattern Syntax
- Blank lines and comments: Lines starting with
#are comments. Blank lines are ignored. - Literal filenames:
config.localignores any file named config.local in any directory. - Wildcards:
*.logignores all files ending in .log.*matches any characters except /. - Directory matching:
node_modules/with a trailing slash matches only directories, not files. - Recursive wildcards:
**/logsmatches logs directories anywhere in the tree.**matches zero or more directories. - Character ranges:
[abc]matches a, b, or c.[0-9]matches any digit. - Negation:
!important.lognegates a previous pattern, forcing Git to track the file even if earlier rules excluded it. - Relative paths: Patterns without a leading slash are relative to the .gitignore location.
/configonly matches config in the same directory as .gitignore, not subdirectories.
Pattern Examples
Common Categories to Ignore
- Dependencies: node_modules, vendor, venv, Pods -- these are installed via package managers and shouldn't be committed.
- Build outputs: dist, build, out, target -- generated during compilation and can be recreated.
- IDE configurations: .vscode/settings.json, .idea, *.sublime-workspace -- personal preferences that vary by developer.
- OS files: .DS_Store (macOS), Thumbs.db (Windows), *.swp (Vim) -- system-generated files with no project value.
- Environment files: .env, .env.local, secrets.json -- contain API keys, passwords, and other sensitive data.
- Logs and temporary files: *.log, tmp/, cache/ -- debugging output and cached data.
- Test coverage: coverage/, .nyc_output/ -- generated reports that can be recreated by running tests.
Global .gitignore
You can create a global .gitignore that applies to all repositories on your machine. This is useful for OS-specific files and IDE preferences:
Handling Already-Tracked Files
Adding a pattern to .gitignore doesn't affect files already tracked by Git. If you accidentally committed a file that should be ignored, remove it from tracking while keeping the local copy:
Frequently Asked Questions
What is a .gitignore file?
A .gitignore file tells Git which files and directories to ignore when tracking changes. It prevents unnecessary files like build artifacts, dependency folders (node_modules), IDE configs, compiled binaries, and sensitive files (.env) from being committed to your repository. Each line in the file is a pattern that matches files or directories to exclude.
How does .gitignore pattern matching work?
Gitignore uses glob patterns: * matches any characters except /, ** matches directories recursively, ? matches a single character, [abc] matches character sets, and ! negates a pattern. A trailing / matches only directories. Lines starting with # are comments. Patterns are matched relative to the .gitignore file's location.
Can I have multiple .gitignore files?
Yes. You can place .gitignore files in any directory, and their rules apply to files in that directory and its subdirectories. For example, a frontend/.gitignore can have React-specific rules while backend/.gitignore has Node.js-specific rules. You can also configure a global gitignore (~/.gitignore_global) for patterns that apply to all your repositories, like OS files (.DS_Store) and IDE configs.
How do I ignore a file that is already tracked?
Adding a file to .gitignore does not stop tracking files already committed. You must first remove the file from Git's index with git rm --cached filename (this keeps the local file but removes it from version control), then commit the change. After that, the .gitignore rule will take effect and Git will stop tracking changes to the file.
What files should always be in .gitignore?
Always ignore: environment files (.env, .env.local) containing secrets, dependency directories (node_modules, vendor, venv), build outputs (dist, build, out), OS files (.DS_Store, Thumbs.db), IDE configs (.idea, .vscode/settings.json), log files (*.log), coverage reports (coverage/), and compiled binaries. Never commit API keys, passwords, private keys, or credentials.
Should I commit .gitignore itself?
Yes. The .gitignore file should be committed to your repository so all contributors ignore the same files. It documents which files are intentionally excluded from version control. The exception is personal IDE settings, which belong in a global gitignore instead of the project's .gitignore.
What is the difference between .gitignore and .git/info/exclude?
Both tell Git to ignore files, but .gitignore is tracked and shared with all repository users, while .git/info/exclude is local to your clone and not committed. Use .gitignore for project-wide exclusions (node_modules, build/) and .git/info/exclude for personal exclusions that only apply to your workflow.
How do I ignore everything except certain files?
Use a wildcard to ignore everything, then negate specific files or directories. For example, to keep only .txt files: * (ignore all), !*.txt (except .txt files), !*/ (don't ignore directories, so Git can traverse them). Negation patterns must come after the ignore pattern.
Why is my .gitignore not working?
Common causes: (1) The file is already tracked -- remove it with git rm --cached. (2) Typo in the pattern -- test with git check-ignore -v filename. (3) Wrong .gitignore location -- patterns are relative to the .gitignore file's directory. (4) Pattern is too broad or too specific. (5) Git cache issue -- try git rm -r --cached . && git add . to refresh.
Can .gitignore patterns use regular expressions?
No. Gitignore uses glob patterns (shell wildcards), not regular expressions. Use * for wildcards, ** for recursive directory matching, ? for single character matching, and [abc] for character classes. If you need regex-level control, use git update-index --skip-worktree instead.
Privacy & Limitations
- All calculations run entirely in your browser -- nothing is sent to any server.
- Results are computed locally and should be verified for critical applications.
Related Tools
- Bcrypt Generator -- Generate bcrypt password hashes with configurable rounds
- Unix Permissions Calculator -- Convert between symbolic (rwx) and octal unix permissions
- QR Code Scanner -- Scan and decode QR codes from uploaded images
- JSON Flattener -- Flatten nested JSON objects into dot-notation key-value pairs
Related Tools
View all toolsBig-O Notation Visualizer
Interactive plot of O(1) through O(n!) complexity curves with operation count comparison
JSON Formatter
Format and beautify JSON with proper indentation
JSON Validator
Validate JSON syntax and show errors
CSV to JSON Converter
Convert CSV data to JSON format with auto-detection
JSON to CSV Converter
Convert JSON arrays to CSV format with nested object handling
JWT Decoder
Decode JWT tokens and display header and payload
.gitignore Generator FAQ
What is a .gitignore file?
A .gitignore file tells Git which files and directories to ignore when tracking changes. It prevents unnecessary files like build artifacts, dependency folders (node_modules), IDE configs, compiled binaries, and sensitive files (.env) from being committed to your repository.
How does .gitignore pattern matching work?
Gitignore uses glob patterns: * matches any characters except /, ** matches directories recursively, ? matches a single character, [abc] matches character sets, and ! negates a pattern. A trailing / matches only directories. Lines starting with # are comments. Patterns are matched relative to the .gitignore location.
Can I have multiple .gitignore files?
Yes. You can place .gitignore files in any directory, and their rules apply to files in that directory and its subdirectories. You can also set a global gitignore (~/.gitignore_global) for patterns that apply to all your repositories, like OS files (.DS_Store) and IDE configs.
How do I ignore a file that is already tracked?
Adding a file to .gitignore does not stop tracking files already committed. You must first remove the file from tracking with 'git rm --cached filename' (keeps the local file but removes from git), then commit. After that, the .gitignore rule will take effect.
What files should always be in .gitignore?
Always ignore: environment files (.env) containing secrets, dependency directories (node_modules, vendor), build outputs (dist, build), OS files (.DS_Store, Thumbs.db), IDE configs (.idea, .vscode/settings.json), log files, coverage reports, and compiled binaries. Never commit secrets or credentials.