A .env file is committed to the repository: what to do

.env file is not committed · security.env_not_committed

Why it matters

A tracked .env file is a leak even if the repository is private today: every clone, fork and CI cache carries it. Remove it from the index, rewrite history if it held real values, and rotate them.

How to fix it

What to do: Add .env and other secret files to .gitignore.

# Environment files
.env
.env.local
.env.*.local
*.env

# Keys and secrets
*.pem
*.key
credentials.json


If .env was already committed: git rm --cached .env.

Does your repository pass this check?

Free for public GitHub repositories, no account needed. 50+ DevOps and security checks in about ten seconds.

Related checks