How do you stop secrets being committed to Git in the first place?
BeginnerScenarioPipelines at scale
Answer
Situation read → Catch it as early as possible: on the laptop, at push, and in CI, because each layer misses some cases.
What I'd do →
- Pre-commit hook with gitleaks:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.2
hooks:
- id: gitleaks
- Push protection in GitHub (secret scanning) blocks pushes containing known token formats.
- CI scan of the whole history on each PR (
gitleaks detector TruffleHog), since hooks can be skipped. - Remove the reason: use OIDC and runtime secret managers so there are fewer secrets for developers to handle at all.
- If one gets through: rotate first, then clean history.
Why → Layered checks catch what any single check misses, and pre-commit gives the fastest feedback.
Interview tip → Mention that pre-commit hooks are optional on the client, so server-side checks are required.
More on Pipelines at scale
The CI pipeline takes 45 minutes. Developers want it under 10. How do you approach it?IntermediateYou have a monorepo with 40 services. Every commit builds and tests all of them. How do you fix that?AdvancedFlaky tests fail 1 in 5 runs and developers just click "re-run". How do you fix this culture and the tests?BeginnerYour self-hosted GitHub runners can't keep up at peak and sit idle at night. How do you run them at scale?AdvancedDocker builds in CI take 12 minutes because every runner starts with an empty cache. How do you speed them up?IntermediateHow do you secure the software supply chain from commit to production?Advanced