← 返回命令列表

Linux command

git-secrets 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Install hooks in repository

git secrets --install

Add AWS patterns

git secrets --register-aws

Add custom pattern

git secrets --add '[pattern]'

Scan repository

git secrets --scan

Scan specific file

git secrets --scan [file.txt]

List patterns

git secrets --list

说明

git-secrets prevents committing secrets and credentials to Git repositories. It installs pre-commit hooks that scan staged changes against configurable patterns, blocking commits that match known secret formats. Created by AWS Labs, it includes built-in patterns for AWS credentials and supports custom patterns for other types of secrets.

参数

--install
Install hooks in current repo.
--register-aws
Add AWS secret patterns.
--add _pattern_
Add forbidden pattern.
--add-allowed _pattern_
Add allowed pattern (exception).
--scan
Scan repository for secrets.
--scan-history
Scan entire commit history.
--list
List registered patterns.
--add-provider _cmd_
Add secret provider command.

FAQ

What is the git-secrets command used for?

git-secrets prevents committing secrets and credentials to Git repositories. It installs pre-commit hooks that scan staged changes against configurable patterns, blocking commits that match known secret formats. Created by AWS Labs, it includes built-in patterns for AWS credentials and supports custom patterns for other types of secrets.

How do I run a basic git-secrets example?

Run `git secrets --install` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --install do in git-secrets?

Install hooks in current repo.