AI-powered Git commit message generator that runs locally with Ollama.
git-auto-commit analyzes your repository diff and generates a commit message
in a strict PREFIX: description format.
- AI-generated commit messages
- Strict
PREFIX: descriptionvalidation - Automatic retries for invalid model output
- Diff size limiting to prevent context overflow
- Consolidated or per-file commit mode
- Dry-run mode
- Fully local execution (no external API)
- Python 3.11 or 3.12 recommended
- Git
- Ollama running locally
Python 3.14+ is not recommended due to current LangChain compatibility.
FEATFIXREFACTORPERFDOCSSTYLETESTCHORE
Expected format:
PREFIX: clear and concise description
Example:
FEAT: add JWT authentication middleware
- Install Ollama: https://ollama.com
- Start Ollama:
ollama serve- Pull a recommended model:
ollama pull llama3:8b- Clone and install this project:
git clone https://github.com/ViniciusCMB/git-auto-commit.git
cd git-auto-commit
pip install -e .Basic usage:
git-auto-commitGenerate a message without committing:
git-auto-commit --dry-runUse a specific model:
git-auto-commit --model llama3:8bLimit diff size:
git-auto-commit --max-diff 4000Commit per file instead of a single consolidated message:
git-auto-commit --per-file- Reads staged and unstaged changes
- Truncates the diff if it is too large
- Sends diff context to a local Ollama model
- Validates model output against commit format rules
- Retries up to 3 times when output is invalid
- Commits if a valid message is produced
If the model output is invalid, the tool:
- Tries to extract the first valid line
- Reinforces formatting instructions
- Retries up to 3 times
- Fails safely if still invalid
This keeps behavior robust even with smaller models such as gemma3:1b.
llama3:8bqwen2.5:7bmistral:7b
Install development tooling:
pip install black pylintRun formatter:
black git_auto_commitRun linter:
pylint git_auto_commitFor contribution workflow and roadmap, see CONTRIBUTING.md.
- Uses
subprocesswithoutshell=True - No external API calls
- Repository data remains local
- Conventional Commit scopes
- Pre-commit hook integration
- PR summary generation
- CI mode
- Multi-step agent version
Pull requests are welcome. See CONTRIBUTING.md for the standard process.
MIT License