AI‑Powered One‑Command Git Commit Message Beautifier for Clean Project History

The article introduces the open‑source tool git‑rewrite‑commits, shows how to install Ollama, configure its cloud model, and run a single npx command that uses AI to rewrite messy Git commit messages and then force‑push the cleaned history.

Java Companion
Java Companion
Java Companion
AI‑Powered One‑Command Git Commit Message Beautifier for Clean Project History

Repository

GitHub repository https://github.com/f/git-rewrite-commits (≈1.2k stars) provides the git-rewrite-commits CLI that rewrites existing git commit messages using AI and then requires a forced push.

Prerequisites

Supports OpenAI GPT or a local Ollama model. The example uses Ollama’s cloud model. Install Ollama following its quick‑start guide (https://docs.ollama.com/quickstart) and obtain a quota by signing in with ollama signin.

Core command

npx git-rewrite-commits --provider ollama --model qwen3-coder:480b-cloud --min-quality-score 10 --language zh --verbose

Additional options are listed with npx git-rewrite-commits --help.

Example workflow (personal blog project)

Run the command; the tool prompts “Confirm? (y)”. Enter y.

The rewrite process starts.

When the AI has generated new commit messages, the tool asks “Rewrite? (y)”. Confirm with y to apply the changes.

After rewriting, the tool displays a forced‑push reminder.

Execute git push --force-with-lease to update the remote repository.

Post‑rewrite verification and recovery

git log --oneline

– view the rewritten history.

If the result is satisfactory, keep the forced push.

If problems occur, restore the original branch with git reset --hard backup-main-1765263878856.

Delete the temporary backup branch with git branch -D backup-main-176526387885.

Summary

The git-rewrite-commits tool leverages an AI model (e.g., Ollama’s qwen3-coder:480b-cloud) to generate clean, standardized commit messages for repositories with poorly written histories, allowing the entire rewrite and push to be performed with a single CLI invocation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AIGitOllamacommand-line toolcommit-message automationgit-rewrite-commits
Java Companion
Written by

Java Companion

A highly professional Java public account

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.