Flask .gitignore template
The Flask template covers Python bytecode, environments and test caches, and adds the instance folder, which is the framework's own convention for uncommitted configuration.
At a glance
- Category
- Framework
- Patterns in this template
- 15 rules
- Directories ignored
- 10 of the 15 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes. Nothing here matches file manager or editor artefacts.
- Typical companions
- Python for the complete cache and packaging rules, plus an OS template.
In detail
instance is the rule that makes this template worth adding on top of Python. The framework supports an instance folder that sits outside the package and holds anything specific to this deployment: the configuration file with the secret key and database URL, a SQLite file, uploaded content. The framework knows how to load configuration from it, and the convention is that it is never committed.
That convention is more useful than it first looks, because it gives you one directory to ignore instead of a list of individual files. A project that keeps its config in instance/config.py has a single rule protecting it, and a new developer who sees an empty instance folder understands immediately that something is expected there.
.webassets-cache is the cache directory used by the asset bundling extension, holding compiled and merged stylesheets and scripts keyed by content. It is regenerated on demand and specific to one machine's filesystem layout. Committing it produces a cache that never hits, because the keys were computed against paths that do not exist on the machine reading them.
The Python rules underneath cover bytecode, virtual environments, packaging output and the test caches: __pycache__, *.pyc, venv, .venv, dist, build, *.egg-info, htmlcov, .tox, .coverage and .pytest_cache. That is a smaller set than the standalone Python template, so pairing the two is still worthwhile if you use type checking or linting caches.
The .env rule matters here for the same reason it does everywhere in this ecosystem: the convention is to load configuration from the environment, and in development that environment comes from a file on disk holding the real database URL and the real API keys.
Examples
instance/
.webassets-cache
*.pyc
__pycache__/
*.py[cod]
.env
.venv/
venv/
dist/
build/
*.egg-info/
htmlcov/
.tox/
.coverage
.pytest_cache/15 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- instance/ is unanchored, so a directory of that name anywhere in the project is ignored. That is usually what you want, but it will also swallow a test fixture folder named instance.
- Ignoring the instance folder means a new clone has no configuration at all and fails at startup. Document what belongs there, or ship an example file outside the folder.
- This template omits .mypy_cache and .ruff_cache. Add the Python template alongside it if you use either tool.
Try it: .gitignore Generator
Pick one or more templates, tick the common additions you want, and copy or download the combined .gitignore.
.gitignore Generator
LOCAL · Browser-OnlyGenerate comprehensive .gitignore files by combining templates for languages, frameworks, IDEs, and operating systems
Language
Framework
IDE
OS
Build Tool
Infrastructure
Common Additions
Preview
Select templates or common additions to generate a .gitignore file.
Related .gitignore templates
All .gitignore templates →Python .gitignore template
A line by line read of the Python .gitignore template: bytecode caches, virtual environments, packaging output, test caches and the lib/ rule that bites.
Django .gitignore template
The Django template adds four framework rules to the usual Python ones: local settings, the SQLite database, uploaded media and collected static files.
Docker .gitignore template
A small template with two rules worth questioning: it ignores .dockerignore, and it ignores every compose file except two, which suits few projects.
Rails .gitignore template
The Rails template is built around the encrypted credentials system: the encrypted file is committed, the key that decrypts it never is. Every rule explained.
Spring Boot .gitignore template
The Spring Boot template covers both build tools at once and adds sections for three IDEs, which makes it broad but leaves application secrets uncovered.
.NET .gitignore template
The .NET template covers bin, obj and NuGet output, and ignores launchSettings.json, which holds the launch profiles and environment variables for local runs.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS
- .env Editor & Validator Edit and validate .env files online - detect duplicates, mask secrets, generate .env.example