Your "fix typo" commits, now with AI-generated dignity
A CLI tool that rewrites git history with conventional commit messages using local Ollama or OpenAI models.

What it does
git-rewrite-commits (alias: grec) analyzes your staged changes or existing commit history, feeds the diffs to an AI model, and spits out proper conventional commit messages—feat(scope): description and all that. It can rewrite your entire history via git filter-branch or hook into your workflow with opt-in pre-commit and prepare-commit-msg hooks.
The interesting bit
The tool is surprisingly paranoid in a good way: it requires explicit consent before sending diffs to remote APIs, auto-redacts keys and passwords, and always creates backup branches before rewriting history. For the privacy-conscious, it runs entirely local via Ollama—no code leaves your machine. There’s also a COMMIT_MESSAGE.md convention for project-specific guidelines, which is a nice touch for teams with actual standards.
Key highlights
- Works with OpenAI GPT or local Ollama models; configurable via git config
- Dry-run mode previews changes before you nuke your history
- Smart filtering skips already well-formed commits
- Multi-language support and custom templates for JIRA-style workflows
- Batch processing with rate limiting for large histories
npx grec --stagedgenerates messages for uncommitted changes
Caveats
- Rewriting history changes commit hashes and requires force-pushing; the README repeatedly warns against using this on shared branches without team coordination
- Remote AI providers receive your file lists and diffs—explicit opt-in required, but still worth noting for sensitive codebases
- Hooks are opt-in via git config; the tool won’t magically work after installation
Verdict
Useful if you’re cleaning up a personal repo before open-sourcing, or if your team’s commit history looks like a stream of consciousness. Skip it if you don’t trust AI with your diffs, or if your coworkers will murder you for force-pushing main.