git rm --cached .env git commit -m "Remove .env from tracking" git push
# Database credentials DB_HOST=localhost DB_PORT=5432 DB_USERNAME=myuser DB_PASSWORD=mypassword DB_NAME=mydatabase
Creating a sample file is simple. Look at your current .env and strip out the secrets: .env.sample
of keys were needed to make the app work. Alex didn't want to share the actual secret passwords, but Sam needed a "map" of the vault. So, Alex created a new file called .env.sample Inside this file, Alex wrote:
To close, here is a checklist you can print out or pin to your team's Slack channel. git rm --cached
Enter (sometimes called .env.example or .env.dist ).
The major rule is that the actual .env file, which holds your real secrets, should be committed to version control. This is a critical security practice, as committing this file would expose all your credentials to anyone with access to the repository. So, Alex created a new file called
Example .env.sample :
The developer then opens the newly created .env file and swaps out the placeholders with their personal local credentials. 3. Modifying Configuration Safely When a feature requires a new environment variable: