Git Commit Analyzer is a powerful Git plugin that leverages AI to automatically generate meaningful commit messages based on your staged changes. It uses Ollama to analyze git diffs and propose commit messages following the Git Flow format.
- Automatic generation of Git Flow compliant commit messages
- Powered by Ollama for local AI processing
- Interactive mode allowing users to use, edit, or cancel the proposed commit message
- Multi-language support (English and Simplified Chinese)
- Cross-platform compatibility (Linux, macOS, Windows)
- Customizable with your personal Git signature
- Support for model selection and persistence
- Git (version 2.0 or later)
- Ollama installed and running (https://ollama.com/download)
- At least one language model installed in Ollama
The fastest way to install Git Commit Analyzer with a single command:
bash -c "$(curl -fsSL https://sh.zhanghe.dev/install-git-ca.sh)"This will automatically:
- Detect your operating system
- Install all dependencies (Git, Rust, Ollama)
- Build and install the plugin
- Configure your environment
- Set up Git configuration
Alternatively, you can install via Homebrew:
brew tap zh30/tap
brew install git-ca
After installation, you can immediately use the git ca command.
-
Clone the repository:
git clone https://github.com/zh30/git-commit-analyzer.git cd git-commit-analyzer -
Build the project:
cargo build --release -
Create a directory for Git plugins (if it doesn't exist):
mkdir -p ~/.git-plugins -
Copy the compiled binary to the plugins directory:
cp target/release/git-ca ~/.git-plugins/ -
Add the plugins directory to your PATH. Add the following line to your
~/.bashrc,~/.bash_profile, or~/.zshrc(depending on your shell):export PATH="$HOME/.git-plugins:$PATH" -
Reload your shell configuration:
source ~/.bashrc # or ~/.bash_profile, or ~/.zshrc
-
Clone the repository:
git clone https://github.com/zh30/git-commit-analyzer.git cd git-commit-analyzer -
Build the project:
cargo build --release -
Create a directory for Git plugins (if it doesn't exist):
mkdir %USERPROFILE%\.git-plugins -
Copy the compiled binary to the plugins directory:
copy target\release\git-commit-analyzer.exe %USERPROFILE%\.git-plugins\ -
Add the plugins directory to your PATH:
- Right-click on 'This PC' or 'My Computer' and select 'Properties'
- Click on 'Advanced system settings'
- Click on 'Environment Variables'
- Under 'System variables', find and select 'Path', then click 'Edit'
- Click 'New' and add
%USERPROFILE%\.git-plugins - Click 'OK' to close all dialogs
-
Restart any open command prompts for the changes to take effect.
After installation, you can use Git Commit Analyzer in any Git repository:
-
Stage your changes in your Git repository (using the
git addcommand). -
Run the following command:
git ca -
If it's your first time running the command, you'll be prompted to select a model from your installed Ollama models.
-
The program will analyze your staged changes and generate a suggested commit message.
-
You can choose to use the suggested message, edit it, or cancel the commit.
To change the default model at any time, run:
git ca model
To set the output language for AI-generated commit messages, run:
git ca language
Available languages:
- English (default)
- Simplified Chinese (简体中文)
The selected language will determine the language of the commit message generated by the AI model. Note that this affects the AI's prompt language, not the interface language.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- The Rust community for providing excellent libraries and tools
- Ollama for providing local AI model support