Gitleaks
Fast Git history and working-tree secret scanner
WHAT IS IT?
Gitleaks is a static secret detection tool written in Go that scans Git repositories, commit histories, and plain directories using combined regex patterns and Shannon entropy thresholds.
WHY USE IT? // PRACTICAL USE CASES
Deleting a `.env` file in a later commit does not remove the secret from `.git/objects`. Gitleaks walks the entire Git commit graph in seconds to verify that no historical commit leaked credentials.
- [1] Pre-commit hook enforcement (`gitleaks protect --staged`) to block accidental key commits
- [2] Auditing full historical git commits (`gitleaks git`) before open-sourcing a repository
- [3] Scanning unindexed directories and configuration backups (`gitleaks dir`)
HOW DO I GET IT? // SAFE INSTALLATION GUIDANCE
Install from OS repositories (`pacman -S gitleaks`, `brew install gitleaks`) or download signed release binaries from `github.com/gitleaks/gitleaks/releases`.
HOW DOES IT WORK? // INTERNAL ARCHITECTURE OVERVIEW
Gitleaks streams git diffs or filesystem blobs through compiled regular expression pre-filters and evaluates matched token groups against entropy calculations and allowlists defined in `.gitleaks.toml`.