Format
KEY=value | Basic key-value pair |
KEY="value with spaces" | Quoted value |
# Comment | Comment line |
export KEY=value | Export to environment (some tools) |
KEY=${OTHER_KEY}/path | Variable expansion (some tools) |
Best Practices
.env | Local environment (never commit) |
.env.example | Template with placeholder values (commit this) |
.env.production | Production overrides (never commit) |
echo '.env*' >> .gitignore | Ignore all .env files |