Secrets

.env files with secrets in the repository

Do not commit .env files that contain real secrets. Commit an example file with empty values instead.

Why it matters

A committed .env is the fastest way to hand over database passwords and API keys. The history keeps it even after deletion.

An example file gives new developers the list of variables without exposing the values.

How to fix it

  1. Add .env to .gitignore

  2. Commit .env.example with empty values

  3. Remove the file from history if it was committed

  4. Rotate every secret it contained

Prompt for an AI assistant

Copy the text below and paste it into an AI assistant.

You are the person improving this website. Check the item below and fix it if it applies to the site.

Item: .env files with secrets in the repository
Summary: Do not commit .env files that contain real secrets. Commit an example file with empty values instead.
Steps:
1. Add .env to .gitignore
2. Commit .env.example with empty values
3. Remove the file from history if it was committed
4. Rotate every secret it contained
References:
- Secrets Management (OWASP) (https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html)

Constraints:
- Keep the existing design and tone of voice.
- Show the file or section you changed and the suggested final wording.
- Do not decide ambiguous points alone; give options and a recommendation.
- Do not change anything outside the listed item.

Related checks

References

Check your site now

Enter a URL and find what is missing before launch, for free.

Run audit