safegit v0.26.0 /safegit scrub
On this page

Reference for the safegit scrub command group — subcommands, flags, arguments, and usage details for the scrub group in the safegit CLI.

#safegit scrub

surgically rewrite git history to remove or replace sensitive content using 4 subcommands (file, match, run, verify) that operate on all commits, trees, and blobs in the repository

#scrub file

replace or remove a specific file across all commits in the repository history, rewriting each affected commit tree to either substitute the file contents with a sanitized version or delete the file entirely from every historical snapshot

Effect: mutating · consequential (prompts before running; --approve-consequential skips)

#Flags

Flags
NameShortTypeDefaultEnvDescription
--fromstrfirst commit hash to include when rewriting history (default: root commit)
--reasonstrmandatory audit trail message explaining why this scrub operation is needed
--remap-shas-instrglob selecting files whose full 40-character commit hashes are remapped to the rewritten SHAs during the walk, keeping hash-referencing files like JSONL changelogs self-consistent at every commit (repeatable; same matching semantics as --scope; not applied inside submodule histories)

#Arguments

Arguments
NameRequiredDescription
fileyesrepository-relative path to the file that should be scrubbed from history

#scrub match

replace all occurrences of a regex pattern across every blob in the repository history, rewriting commit trees to substitute matched text with a replacement string so that sensitive values like secrets and credentials are permanently removed from all historical snapshots

Effect: mutating · consequential (prompts before running; --approve-consequential skips)

#Flags

Flags
NameShortTypeDefaultEnvDescription
--patternstrregular expression pattern to search for across all blobs in history
--reasonstrmandatory audit trail message explaining why this scrub operation is needed
--scopestrglob pattern limiting which file paths are searched (e.g. '.env', 'config/*')
--remap-shas-instrglob selecting files whose full 40-character commit hashes are remapped to the rewritten SHAs during the walk, keeping hash-referencing files like JSONL changelogs self-consistent at every commit (repeatable; same matching semantics as --scope; not applied inside submodule histories)
--replacestrliteral string to substitute for each regex match found in history
--mangleboolreplace matches with random printable ASCII of same length
--fromstrfirst commit hash to include when rewriting history (default: root commit)
--entire-historyboolrewrite all commits from the root of the repository to HEAD

#scrub run

execute a multi-operation scrub recipe from a TOML file, applying all pattern replacements and file removals across history in a single coordinated pass with topological commit ordering, overlap detection between operations, and automatic verification that no matched content survives in the rewritten object store — use --diff to preview all changes as unified diffs before committing to the rewrite

Effect: mutating · consequential (prompts before running; --approve-consequential skips)

#Flags

Flags
NameShortTypeDefaultEnvDescription
--reasonstrmandatory audit trail message explaining why this scrub operation is needed
--diffboolpreview what would change without modifying any objects, showing unified diffs
--limitint50maximum number of blob diffs to show in --diff mode (default: 50)
--remap-shas-instrglob selecting files whose full 40-character commit hashes are remapped to the rewritten SHAs during the walk, keeping hash-referencing files like JSONL changelogs self-consistent at every commit (repeatable; same matching semantics as --scope; not applied inside submodule histories)
--fromstrfirst commit hash to include when rewriting history
--entire-historyboolrewrite all commits from the root of the repository to HEAD

#Arguments

Arguments
NameRequiredDescription
recipeyespath to the TOML recipe file containing scrub operations

#scrub verify

check all scrub policies defined in the repository configuration to confirm that previously scrubbed secrets and sensitive patterns remain completely absent from every object in the git object store, scanning blobs, commit messages, and tag annotations and reporting detailed per-policy pass or fail results with match locations for any violations found

Effect: read_only

Search