gitmyhub

git-rewrite-commits

TypeScript ★ 1.4k updated 1mo ago

AI-powered git commit message rewriter using Ollama or GPT

A command-line tool that uses AI to rewrite messy git commit messages into clean, conventional-commit-style history, run once or automatically via a git hook.

TypeScriptNode.jsOpenAI APIOllamasetup: easycomplexity 2/5

This tool uses AI to rewrite the commit messages in a git repository's history. Commit messages are the short descriptions developers write each time they save a change to a codebase. When those messages are vague or inconsistent, this tool can go back through all of them and replace them with cleaner, more descriptive ones following a standard format called conventional commits, which uses prefixes like "feat" or "fix" to categorize each change.

You can run it without installing anything, just by typing a single command in a terminal. It supports OpenAI's models for the rewriting, or a local tool called Ollama that processes everything on your own machine without sending your code anywhere. For repositories containing sensitive code or credentials, the local option is recommended.

The tool can also install hooks into git so that every new commit you make gets an AI-generated message automatically, either shown as a preview for you to accept or written directly into the commit editor.

An important caution: rewriting commit history changes the internal identifiers for every commit and requires a force-push to update the remote copy of the repository. This is disruptive for shared branches where other people have already pulled the old commits. The README strongly recommends using this only on personal projects, feature branches before they are merged, or repositories you are about to make public for the first time.

A dry-run mode lets you preview what the new messages would look like before anything is changed, and the tool always creates a backup branch before making any modifications.

Where it fits