rewrite-commits

Generates Conventional Commit messages with an OpenAI-compatible completions endpoint, previews the results, and rewrites history with git-filter-repo after confirmation.

By default, generated messages are subject-only. Use --body to generate a subject and body.

Usage

git-wrangler rewrite-commits [options]

Options

FlagDefaultDescription
--repo <path>Target exactly one repository instead of discovering recursively.
--no-fetchfalseUse local remote-tracking refs without fetching origin first.
--batch-size <number>10Commits per API request (must be between 1 and 50).
--max-chars-per-commit <number>3000Maximum redacted context characters per commit.
--rpm <number>300Maximum API requests to start per minute.
--timeout <seconds>90API timeout in seconds.
--skip-conventionalfalseSkip commits that already use Conventional Commits.
--bodyfalseGenerate a subject and body instead of subject only.
--yesfalseSkip the data-send and rewrite confirmation prompts.
--guidedfalseInteractively configure command options before execution.

AI provider, base URL, model, and API key come from git-wrangler init, git-wrangler config, or supported environment variables.

git and git-filter-repo are required. --batch-size must be between 1 and 50; --max-chars-per-commit, --rpm, and --timeout must be positive integers.

By default, rewrite-commits validates AI settings, then runs git fetch --prune origin for each target repository before scanning commits or sending API requests. Any fetch failure stops the command before scanning, AI generation, preview, confirmation, or mutation. Use --no-fetch for offline or local-only runs; the command warns that local remote-tracking refs may miss remote-only commits before the normal AI data-send confirmation path.

Privacy Controls

The command sends repository name, short commit id, file status, numstat, and redacted diff snippets.

It does not send API keys in commit context and does not include old commit messages in model context.

Sensitive file contents are hidden, including .env, private keys, credential or secret config files, and certificate/key bundles. Diff bodies for common generated, vendor, cache, build, and upload paths are also hidden while file names and stats remain visible. Common secret-like tokens are redacted from diff text.

Flow

  1. Validate AI settings and runtime dependencies.
  2. Refresh origin unless --no-fetch is set.
  3. Scan commit diffs and ask before sending redacted context to the AI endpoint.
  4. Print generated messages for review.
  5. Ask before applying the history rewrite.

Declining either confirmation is a successful no-op before mutation. Old commit messages are not sent as model context.

Use --yes for noninteractive runs after configuring all required values or setting environment variables.

Example

git-wrangler config set ai.model gpt-4o
git-wrangler config set ai.api-key
git-wrangler rewrite-commits

# Rewrite using local remote-tracking refs without refreshing origin
git-wrangler rewrite-commits --no-fetch

[!WARNING] This rewrites Git history. You will need to force-push to update remotes. Prefer git-wrangler push --force for a lease-safe update.