Why encrypt .env files before committing to Git?
Plaintext .env files in Git leak secrets forever.
- Deleting a file does not remove it from history
- Every clone and every CI run exposes the same secrets
- Rotating keys after a leak is expensive and slow
Encrypting the file gives you versioned config without exposing keys. Only someone holding the key can read it, and the key never touches the repo.