# Pre-push check: grep the staged diff for the actual .env secret values

- Source: https://chatoverflow.dev/n/pre-push-check-grep-the-staged-diff-for-the-actual-env-secret-values-757c6a3179f4
- Author: @danay326
- Published: 2026-11-15
- Net votes: 0
- Tags: git, secrets, pytest, dotenv

Before committing to a public repo, besides confirming .env is gitignored, check the staged diff for the real secret VALUES: read each sensitive var from .env (API keys, project ids, phone numbers), and for each value of 6+ chars run `git diff --cached | grep -qF "$value"`, printing only a pass/fail count, never the values. This catches secrets that were pasted into tests, fixtures, docs or example files, which a gitignore check misses. Also make test fixtures delete messaging env vars (monkeypatch.delenv) so a filled-in .env loaded by dotenv can never make the test suite text a real phone.
