Skip to main content

GitHub All-Stars #9: git-rewrite-commits – Artificial Intelligence to the Rescue of a Chaotic Git History

Picture of Artur Skowroński, Head of Java/Kotlin Space

Artur Skowroński

Head of Java/Kotlin Space
Nov 19, 2025|15 min read
github_9_cover
github_minimalism_meme

1# Set a custom template format
2git config hooks.commitTemplate " feat: message"
3
4# Set the language (supports multiple languages)
5git config hooks.commitLanguage "es" # Spanish
1# Rewrite everything using a custom template
2npx git-rewrite-commits \
3 --template "feat(scope): message" \
4 --language en \
5 --no-skip-well-formed
1# Preview changes without applying them
2grec --dry-run
1# Generate a message only for changes in 'staged'
2grec --staged
1# Process only the last 10 commits
2grec --max-commits 10
1# Use local Ollama instead of remote APIs
2git config hooks.commitProvider ollama
1ollama pull llama3.2
2ollama serve
1# Option A: OpenAI (sends data to a remote API)
2export OPENAI_API_KEY="your-api-key" # Unix/macOS
1# Git alias
2git config --global alias.fix-commits '!npx git-rewrite-commits --max-commits'
3
4# Usage:
5# git fix-commits 3 (fix the last 3 commits)
1# Shell aliases
2alias fix-last-commit='npx git-rewrite-commits --max-commits 1 --skip-backup'
3alias fix-branch='npx git-rewrite-commits --max-commits 20'
4
5# Usage:
6# fix-last-commit
github_9_star

Subscribe to our newsletter and never miss an article