Gitleaks: find secrets that were committed to a Git repository
Gitleaks scans Git history, working trees and arbitrary files for passwords, API keys, tokens and private keys using a library of patterns, and is usually run as a pre-commit hook and in CI.
Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?
gitleaks/gitleaks
- Stars
- 30k
- Forks
- 2.3k
- Language
- Go
- Licence
- MIT
- Last push
- 30 Sep 2026
On GitHub: Find secrets with Gitleaks 🔑
Open on GitHubGitleaks (about 30,000 stars on GitHub) is a secret scanner written in Go. Zachary Rice started it in 2018 and still leads the project, with a community of contributors maintaining the detection rules. The tool solves a problem every team meets sooner or later: a credential pasted into a config file, committed, and pushed, where it stays visible in history even after the file is edited. Gitleaks finds such strings before they leave a developer’s machine, or after the fact across an existing repository.
How it works
Gitleaks walks either the commits of a repository or the files of a directory and tests each line against a set of rules. Every rule combines a regular expression with the shape of a known credential (for example an AWS access key, a GitHub token, a Slack webhook or a PEM private key), an optional entropy threshold to catch generic high-randomness strings, and keywords that narrow where the rule is applied. Hits are printed with the file, line, commit and author, so the team knows exactly what to rotate. Findings that are false positives can be listed in a .gitleaksignore file or excluded through an allowlist in a .gitleaks.toml configuration, which can also add rules for your own internal token formats.
Who it is for
- Developers who want a check that stops them from committing a secret by mistake, usually through the pre-commit integration.
- Teams that add secret scanning to CI so that pull requests with leaked credentials are rejected automatically; the official
gitleaks/gitleaks-actioncovers GitHub Actions. - Administrators auditing an old repository before it is made public or handed over.
- Anyone who prefers a scanner that runs locally with no account and no server.
How to install and try it
brew install gitleaks
gitleaks version
gitleaks git --verbose .
gitleaks dir --verbose .
The git subcommand examines the full history of the repository in the current directory; the dir subcommand scans the files on disk and is the right choice for a project that is not under version control. Binaries are on the releases page, and a Docker image is published for CI environments. The README documents the configuration format and the pre-commit setup.
Credit
Gitleaks was created by Zachary Rice and is maintained by him and the contributors listed on GitHub. It is published under the MIT License.
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0306 What is hashing? Hashing turns any data into a fixed length fingerprint that cannot be reversed, used to check files and store passwords. Beginner · Explains an idea · Any system Article Secrets & access 15 Oct 2026
- 0313 What is CI/CD? CI/CD is the habit of automatically testing every code change and, once it passes, deploying it without manual steps. Beginner · Explains an idea · Any system Article Pipelines, runners & hooks 15 Oct 2026
- 0354 sudo rules: give a user exactly the rights they need Write sudoers rules with visudo: full admin for operators, a short list of commands for a deploy account, no-password rules for automation,… Intermediate · Step by step · Linux Article Secrets & access · Users, sudo & hardening 15 Oct 2026
- 0357 Keep secrets out of git: .env files, gitignore and what to do after a leak Load passwords and API keys from an untracked .env file, commit a safe .env.example instead, catch mistakes before they are pushed, and… Beginner · Step by step · Any system Article Housekeeping · Secrets & access 15 Oct 2026
- 0378 Continuous integration explained What continuous integration means, why small frequent merges plus an automated build on every change prevent integration pain, what a good pipeline… Beginner · Explains an idea · Any system Article Pipelines, runners & hooks 15 Oct 2026
- 0379 Your first GitHub Actions workflow: run tests on every push Build a working GitHub Actions pipeline from nothing: a small Python project with a test, a workflow file that runs pytest on… Beginner · Guided project · Any system Article GitHub Actions · Pipelines, runners & hooks 15 Oct 2026
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Dominik +2,365 chars