Skip to content

Demo preview. Courses, instructors, reviews and prices are sample content. Payments are simulated.

XOps, home

Secrets Do Not Belong in Git: A Practical Checklist

Leaked keys are one of the most common causes of cloud incidents. These habits keep secrets out of your repositories.

Farah Siddiqui · 5 min readSample article
Abstract illustration of a shield

Once a secret is committed, deleting the file is not enough. It remains in the history of every clone. The safest approach is to stop secrets from reaching a commit at all.

  • Keep secrets in environment variables or a secrets manager, never in source files.
  • Add .env files to .gitignore and commit an .env.example without values.
  • Run secret detection in a pre-commit hook and again in CI.
  • Prefer short-lived credentials over long-lived keys.
  • If a secret leaks, rotate it first, then clean up the history.
  • Security
  • DevSecOps