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
| Flag | Default | Description |
|---|---|---|
--repo <path> | Target exactly one repository instead of discovering recursively. | |
--no-fetch | false | Use local remote-tracking refs without fetching origin first. |
--batch-size <number> | 10 | Commits per API request (must be between 1 and 50). |
--max-chars-per-commit <number> | 3000 | Maximum redacted context characters per commit. |
--rpm <number> | 300 | Maximum API requests to start per minute. |
--timeout <seconds> | 90 | API timeout in seconds. |
--skip-conventional | false | Skip commits that already use Conventional Commits. |
--body | false | Generate a subject and body instead of subject only. |
--yes | false | Skip the data-send and rewrite confirmation prompts. |
--guided | false | Interactively 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
- Validate AI settings and runtime dependencies.
- Refresh
originunless--no-fetchis set. - Scan commit diffs and ask before sending redacted context to the AI endpoint.
- Print generated messages for review.
- 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 --forcefor a lease-safe update.