Git AI
Git AI is a tool that helps generate commit messages using AI. It simplifies the commit process by automatically generating a short, descriptive commit message based on your code changes.
Features
- Analyzes staged git diffs and generates a commit message summarizing the changes
- Leverages Polyfact's AI API to generate natural language
- Handles large diffs by splitting into multiple API requests
- Customizable options like commit message language, model name, etc.
- Auto-commit mode to directly commit the generated message
- Optional git commit --amend to open editor and refine message
Usage
Prerequisites
Installation
npm install -g @polyfact/git-ai
or
yarn global add @polyfact/git-ai
Configuration
Create a .ai-gitrc
file to customize options.
ai-git init-config
Or set options as CLI flags:
ai-git commit --token YOUR_TOKEN --language english --model gpt-3.5-turbo
Basic Usage
# Auto generate and commit
ai-git commit
# Generate message without auto commit
ai-git commit --no-autocommit
# Open editor to refine message after commit
ai-git commit --editor
Configuration
The CLI and config file options allow customizing the commit message generation:
token
- Polyfact API keymodel
- AI model namemaxTokens
- Max tokens per API requestlanguage
- Commit message languageautocommit
- Directly create commiteditor
- Open editor after commitexclude
- Patterns to exclude from difffilter
- Git diff filter flagtemplate
- Prompt template for AI