.gitignore Generator

Pick your languages and frameworks, get a ready-to-use .gitignore

Generated .gitignore


What Is .gitignore?

A .gitignore file tells Git which files and directories to exclude from version control. Every project generates files that should not be committed: compiled binaries, dependency folders like node_modules/, environment files with secrets (.env), log files, IDE configuration, and OS-specific files like .DS_Store or Thumbs.db.

Without a proper .gitignore, these files clutter your repository, inflate its size, and can accidentally expose sensitive information like API keys and database passwords.

Common .gitignore Patterns

Gitignore patterns use glob-like syntax. A filename like *.log ignores all files ending in .log. A directory name with a trailing slash like node_modules/ ignores that entire directory. A leading slash like /build matches only at the repository root. A leading exclamation mark like !important.log negates a previous ignore rule and forces Git to track that file.

Common patterns include: dependency directories (node_modules/, vendor/, venv/), build outputs (dist/, build/, *.o), environment files (.env, .env.local), and editor files (.idea/, .vscode/, *.swp).

Global vs Local .gitignore

A local .gitignore lives in your repository and is committed with the code. It contains rules specific to the project, like ignoring node_modules/ for a Node.js project. Everyone who clones the repository gets these rules.

A global .gitignore is set per-user and applies to all repositories on your machine. Configure it with git config --global core.excludesfile ~/.gitignore_global. It is ideal for OS files (.DS_Store, Thumbs.db) and personal editor files (.idea/, *.swp) that should not be in every project's .gitignore.

Frequently Asked Questions

How do I ignore a file that is already tracked? Run git rm --cached filename to untrack it, then add the pattern to .gitignore and commit both changes.

Can I have .gitignore files in subdirectories? Yes. Rules in a subdirectory .gitignore apply only within that directory and its children. This is useful for monorepos.

Does .gitignore affect files already committed? No. Gitignore only prevents untracked files from being added. To stop tracking a committed file, use git rm --cached.