On this page
Key takeaways
- gitleaks scans commit history and live changes for many types of secrets.
- trufflehog hunts for leaked credentials across history, files, and even online sources.
- git-crypt encrypts sensitive files while the rest of the repository stays normal.
- detect-secrets, ggshield, and Talisman catch secrets before they enter a commit.
A secret committed to a repository is one of the fastest ways to compromise a project, because credentials in Git history stay there long after the file is removed. API keys, tokens, and passwords slip into commits by accident all the time, and finding them after the fact is much harder than stopping them at the start.
The tools below scan for secrets at different points: before a commit, during review, across existing history, and inside container images and files. Some detect known patterns, some encrypt sensitive files in place, and some plug into the Git hook workflow. Together they give a team several layers of protection around the repository.
Quick comparison
| Tool | Best for | Starting price | Free plan |
|---|---|---|---|
| gitleaks | Scanning for secrets in Git history | Not included | Not included |
| trufflehog | Finding leaked credentials | Not included | Not included |
| git-crypt | Transparent encryption in Git | Not included | Not included |
| detect-secrets | Detecting secrets before commits | Not included | Not included |
| ggshield | Scanning for secrets | Not included | Not included |
| Talisman | Pre-commit secret detection | Not included | Not included |
| SecretScanner | Finding secrets in images and files | Not included | Not included |
The best tools for secrets scanning and repository security
1. gitleaks
- Official site: https://github.com/gitleaks/gitleaks
- Best for: Scanning for secrets in Git history
- Starting price: Not included
- Free plan: Not included
- Pros: Scans history and live changes; Large built-in rule set
- Cons: Needs tuning for false positives; Mostly a command-line tool
gitleaks scans Git repositories for secrets using a large set of detection rules that cover common API keys, tokens, and credential formats. It can check the full commit history, the working tree, and the staged changes, so it finds secrets that were committed long ago as well as ones about to be committed. The tool is a single binary that runs from the command line and in CI.
It is best for auditing a repository's history and for guarding new commits in a pipeline. gitleaks is fast and covers a wide range of services out of the box, which makes it a strong default for teams starting a scanning program. The rules can produce false positives, so a team should plan time to tune ignore rules for its own patterns.
2. trufflehog
- Official site: https://github.com/trufflesecurity/trufflehog
- Best for: Finding leaked credentials
- Starting price: Not included
- Free plan: Not included
- Pros: Deep scanning beyond simple regex; Checks many sources
- Cons: Heavier to run; Results need human review
trufflehog searches for leaked credentials using more than simple pattern matching, checking whether a found string actually behaves like a live secret. It scans Git history, the filesystem, and container images, and it can follow references to online sources where secrets sometimes leak. The verification step helps separate real credentials from harmless lookalike strings.
It is best for a thorough hunt when a team suspects a secret has already escaped, since it casts a wider net than most scanners. trufflehog needs more time and resources to run, and its findings still require a person to confirm and rotate each credential. For a deep audit rather than a quick pre-commit check, it is the strongest option here.
3. git-crypt
- Official site: https://github.com/AGWA/git-crypt
- Best for: Transparent encryption in Git
- Starting price: Not included
- Free plan: Not included
- Pros: Encrypts files transparently; Fits the normal Git workflow
- Cons: Not a secret scanner; Key management is manual
git-crypt encrypts selected files in a repository so that they are stored as ciphertext while authorized developers see them decrypted automatically. It hooks into Git's diff and checkout filters, so the daily workflow stays the same and only the protected files change form. A shared key controls who can read the encrypted content.
It is best for keeping configuration and secrets out of a repository's readable history without splitting them into a separate store. git-crypt protects files at rest in the repo, but it is not a scanner and does not find secrets that are already there. The encryption key still needs careful handling, since losing it means losing access to the files.
4. detect-secrets
- Official site: https://github.com/Yelp/detect-secrets
- Best for: Detecting secrets before commits
- Starting price: Not included
- Free plan: Not included
- Pros: Plugs into pre-commit hooks; Baseline lets old findings be ignored
- Cons: Baseline needs maintenance; Plugin-based rules to configure
detect-secrets scans files for secrets and is designed to run as a pre-commit hook, so it blocks a secret before it enters a commit. A baseline file records existing findings, which lets a team scan new changes without tripping over every old issue at once. Rules come as plugins, so teams can add their own patterns.
It is best for teams that want a guard at the commit boundary with a clear upgrade path, since the baseline makes adoption easier on an existing repository. The trade-off is that the baseline must be kept current, and the plugin approach means a little configuration to match the team's stack. It is a prevention tool first, rather than a full history audit.
5. ggshield
- Official site: https://github.com/GitGuardian/ggshield
- Best for: Scanning for secrets
- Starting price: Not included
- Free plan: Not included
- Pros: Pre-commit, pre-push, and CI modes; Many detector types
- Cons: Ties into a vendor service; Some features need an account
ggshield is a command-line scanner that runs at several points in the workflow, including pre-commit, pre-push, and CI. It detects a broad set of secret types and can check pull requests and diffs, not just full files. The tool is maintained by GitGuardian and can send findings to that service for a shared view.
It is best for teams that want scanning at every stage with one tool, from the developer's machine to the build server. ggshield is easy to drop into an existing hook setup and covers a lot of detectors out of the box. The connection to the vendor means some advanced features require an account, which may not suit a fully self-contained workflow.
6. Talisman
- Official site: https://github.com/thoughtworks/talisman
- Best for: Pre-commit secret detection
- Starting price: Not included
- Free plan: Not included
- Pros: Runs from a single binary; Installs as a hook easily
- Cons: Detection is pattern-based; False positives need tuning
Talisman checks outgoing changes for secrets and is installed as a pre-commit or pre-push hook, often by copying a single binary into the repository. It scans the files about to be committed and blocks the commit when a suspicious string appears. The setup is intentionally small, so a team can adopt it with almost no infrastructure.
It is best for a lightweight guard that lives entirely in the repository and runs before any commit or push. Talisman is pattern-based, so it catches common key and token shapes without needing a service behind it. That same approach can flag harmless strings, so teams should tune its ignore rules to avoid a noisy workflow.
7. SecretScanner
- Official site: https://github.com/deepfence/SecretScanner
- Best for: Finding secrets in images and files
- Starting price: Not included
- Free plan: Not included
- Pros: Scans container images and filesystems; Part of a security toolkit
- Cons: Oriented to images first; Fewer docs than the leaders
SecretScanner looks for secrets in container images and on host filesystems, which covers ground that history-only scanners miss. It walks through image layers and files to find API keys and tokens that were baked into a build, and it is part of the Deepfence security tooling around containers. The tool is packaged as a container itself, so it runs consistently in CI.
It is best for teams shipping container images that want to catch secrets left inside a build before the image is deployed. SecretScanner complements a Git-history scanner by checking the artifact rather than the repository. Its documentation and community are smaller than the leaders in this list, and its focus stays on images and files rather than full Git audits.
How we chose
These tools were chosen to cover secrets at every point where they can enter or hide in a repository, from the moment of a commit to years of history and the final container image. The list pairs pattern scanners, a deep verification engine, an encryption tool, and an image scanner, because no single tool catches everything on its own.
Preference went to actively maintained projects with an install path simple enough to adopt in an afternoon. Secrets scanning only helps if it runs routinely, so the tools here are chosen for fitting into hooks and CI without a large platform purchase, keeping the barrier to a daily scan low.
FAQ
What is the best first tool for secrets scanning?
gitleaks is a strong start, because it is fast, has a large built-in rule set, and runs both on history and on new commits in CI.
Do scanners find every secret?
No. They catch known patterns and shapes, but a determined or unusual credential can slip through, so scanning should be paired with careful review and rotation of anything exposed.
Is git-crypt a scanner?
No, git-crypt encrypts selected files so secrets are not stored in plaintext, but it does not search for secrets that already exist in history.
Should secrets scanning run before commit or in CI?
Both are useful. A pre-commit hook stops a secret early, while a CI scan catches what slips past and checks older history and pull requests.
What should I do if a secret was committed?
Rotate or revoke the credential first, because removing it from Git does not undo the exposure, then scrub it from history with a tool like gitleaks.