.gitignore Generator -- Files for Any Stack

Generate .gitignore files for any language, framework, and IDE

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

0 lines 0 rules
Select templates above to generate your .gitignore file

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.local ignores any file named config.local in any directory.
  • Wildcards: *.log ignores all files ending in .log. * matches any characters except /.
  • Directory matching: node_modules/ with a trailing slash matches only directories, not files.
  • Recursive wildcards: **/logs matches 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.log negates 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. /config only matches config in the same directory as .gitignore, not subdirectories.

Pattern Examples

# Ignore all .txt files *.txt # But track README.txt !README.txt # Ignore node_modules directory anywhere node_modules/ # Ignore build directory only at root /build/ # Ignore all .log files in any logs directory **/logs/*.log # Ignore files matching pattern temp-* *-backup.sql

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:

# Create global gitignore git config --global core.excludesfile ~/.gitignore_global # Edit the file and add patterns # Common additions: .DS_Store, *.swp, .vscode/, .idea/

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:

# Remove single file from tracking git rm --cached .env # Remove directory from tracking git rm -r --cached node_modules/ # Commit the removal git commit -m "Remove ignored files from tracking"

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

Related Tools

View all tools

.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.

Request a New Tool
Improve This Tool