How do you scan a repository's full history with Gitleaks and create a report?

BeginnerHands-onGitleaks
Answer

Short answer

Run Gitleaks in git mode on the repo (it walks every commit), and use --report-format / --report-path to save results as JSON, SARIF or CSV for review or upload to a security dashboard.

Commands

git clone https://github.com/org/shop.git && cd shop
gitleaks git . --report-format json --report-path gitleaks-report.json -v
gitleaks detect --source . --report-format sarif --report-path gitleaks.sarif   # older syntax

Useful options

Option Purpose
--log-opts="--since=2026-01-01" Limit to recent commits (git log options)
--log-opts="main..feature/x" Only commits in a branch range (good for PRs)
--redact Hide secret values in output/logs
--config .gitleaks.toml Custom rules / allowlists
--baseline-path old-report.json Ignore findings already known
--exit-code 0 Report without failing (audit mode)

Reading results

Each finding includes the commit, author, file and line — so you know who to talk to and how long it's been exposed.

What to say in the interview

"gitleaks git on the repo scans every commit; I output JSON or SARIF with --redact so secret values don't leak into logs, use log-opts to limit scope for PRs, and baselines to handle historical findings."

All Security Tools questions Roadmap: Gitleaks — secret scanning

More on Gitleaks