.gitignore generator: files Git should not track
The .gitignore file tells Git which files and folders to ignore in a repository. Without it, Git will track unnecessary files like dependencies, compiled files, secrets, and local configurations, polluting the project history.
What to include in .gitignore
- node_modules/, vendor/, __pycache__/ — installed dependencies.
- .env, .env.local, *.key — environment variables and secrets.
- dist/, build/, out/ — files generated during compilation.
- .DS_Store, Thumbs.db — operating system files.
- *.log, *.tmp, *.cache — temporary files.
- .idea/, .vscode/settings.json — local IDE configurations.
Syntax rules
Lines starting with # are comments. The asterisk (*) matches any sequence of characters. Double slash (**) matches at any directory level. A pattern starting with / applies only to the repository root. Adding ! before a pattern excludes it from ignore.
Global .gitignore
You can create a global .gitignore in your home folder that applies to all your projects: git config --global core.excludesfile ~/.gitignore_global. Use it for OS or IDE-specific files you never want tracked in any project.