git-secrets
Prevents committing passwords and sensitive information to git repositories using pattern matching and hooks
git-secrets is a git plugin that scans commits, commit messages, and merge histories to prevent sensitive information from being committed to repositories. It uses configurable regular expression patterns to detect prohibited content like passwords, API keys, and other credentials before they enter the git history.
The tool operates through git hooks (pre-commit, commit-msg, and prepare-commit-msg) that automatically scan content during the commit process. When prohibited patterns are detected, the commit is rejected. It includes built-in AWS credential detection patterns and can scan for AWS Access Key IDs, Secret Access Keys, and account IDs. Users can also define custom patterns and secret providers for organization-specific credential formats.
Developers working with cloud services, DevOps teams, and security-conscious organizations would use git-secrets to add an automated layer of protection against credential leaks. The tool supports scanning entire repository histories with git secrets --scan-history, making it useful for auditing existing codebases before making repositories public. It can be configured globally to automatically protect all new repositories or applied selectively to specific projects.
Installation
# via Homebrew
brew install git-secrets
# via Make
make install
Alternatives & related tools
Git Extras
A collection of extra git subcommands, including git-ignore, git-setup, git-changelog, git-release, git-effort, git-squash and git-pull-request.
forgit
Interactive Git command wrapper using fzf for fuzzy selection of files, commits, branches, and more
tig
ncurses-based text-mode interface for browsing Git repositories and staging changes
gh-dash
Terminal UI for GitHub that lists configurable pull request and issue sections, with vim-style hotkeys, custom actions, and a YAML config file.
git-lfs
Git extension for managing large files by storing them outside the repository with pointer files
add a badge to your README
Maintain git-secrets? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/git-secrets?utm_source=badge)<a href="https://www.trmn.sh/tools/git-secrets?utm_source=badge"><img src="https://www.trmn.sh/badge/git-secrets.svg" alt="Featured on trmn" height="20"></a>