← all repositories
f/git-rewrite-commits

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.

1.4k stars TypeScript Other AI
git-rewrite-commits
Velocity · 7d
+6.7
★ / day
Trend
steady
star history

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 --staged generates 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.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.