llmgit is a Git enhancement tool powered by large language models, providing an intelligent Git operation experience.
- 🤖 AI Commit Message Generation: Automatically analyze code changes and generate professional commit messages
- 🔍 AI Code Review: Use AI to review commits, identify potential issues and improvement suggestions
- 📝 AI Diff Explanation: Explain code changes in plain language
- 📋 Auto-generate CHANGELOG: Generate CHANGELOG automatically from commit history
- 🔀 PR/MR Description Generation: Auto-generate Pull Request descriptions based on branch differences
- 🌍 Internationalization: Full i18n support with English (default) and Chinese
- 🔄 Full Git Compatibility: All native Git commands work normally
cd projects/llmgit
make build
# The binary will be in build/llmgitOr use Go directly:
go build -o build/llmgitmake install
# Or manually copy build/llmgit to a directory in your PATHBefore first use, you need to initialize the configuration:
llmgit ai init <provider> <api-key> [model]Examples:
# Using OpenAI
llmgit ai init openai sk-xxx gpt-4
# Using DeepSeek
llmgit ai init deepseek sk-xxx deepseek-chat
# Using Qwen
llmgit ai init qwen sk-xxx qwen-turboSupported providers include:
openai- OpenAIdeepseek- DeepSeekqwen- Qwen (通义千问)claude- Anthropic Claudegemini- Google Gemini- And more (run
llmgit ai providersto see the full list)
llmgit supports multiple languages. By default, all output is in English. You can switch to Chinese using:
# Set language via environment variable
export LLMGIT_LANG=zh
# Or use --lang option (affects only the current command)
llmgit --lang zh ai commit
# Or use -l short form
llmgit -l zh ai commitSupported languages:
en(default) - Englishzh/cn/chinese- Chinese
To see all supported LLM providers:
# List all providers
llmgit ai providers
# Or use alias
llmgit ai list-providers
# With Chinese output
llmgit --lang zh ai providers# Stage files first, then use AI to generate commit message
git add .
llmgit ai commit
# Generate commit message in Chinese
llmgit ai commit --lang zh
# Or use short form
llmgit ai commit -l zh
# You can also pass additional git commit arguments
llmgit ai commit --no-verifyCommit Message Format:
The generated commit messages follow the Conventional Commits specification:
<type>(<scope>): <short summary>
[optional detailed description]
generated by llmgit
Types:
feat- A new featurefix- A bug fixdocs- Documentation only changesstyle- Code style changes (formatting, etc.)refactor- Code refactoringperf- Performance improvementstest- Adding or updating testsbuild- Build system or external dependenciesci- CI configuration changeschore- Other changes that don't modify src or test filesrevert- Reverts a previous commit
Scope is optional and can be omitted.
Commit Language Options:
en(default) - Englishzh/cn/chinese- Chinese
Note: The --lang option for commit command only affects the language of the generated commit message, not the tool's output messages.
Custom Commit Prompt Template:
You can customize the prompt template used for generating commit messages:
# Set a custom prompt template directly
llmgit ai set-prompt "You are a Git commit message generator. Analyze the code changes and generate a commit message in {language}. Code changes: {diff}"
# Set prompt from a file
llmgit ai set-prompt prompt.txt
# View current prompt template
llmgit ai set-prompt
# The template supports placeholders:
# - {language} - Will be replaced with language instruction (Use English/Use Chinese)
# - {diff} - Will be replaced with the actual code diffIf no custom prompt is set, the default template will be used.
# Review the latest commit
llmgit ai review
# Review a specific commit
llmgit ai review HEAD~1
llmgit ai review abc123# Explain working directory changes
llmgit ai explain
# Explain changes in a specific file
llmgit ai explain src/main.go
# Show diff with AI explanation
llmgit ai diff# Generate CHANGELOG since last tag
llmgit ai changelog
# Generate CHANGELOG for specified range
llmgit ai changelog v1.0.0..HEAD
# Generate and save to file
llmgit ai changelog --output CHANGELOG.md
# Generate in different formats
llmgit ai changelog --format json
llmgit ai changelog --format yamlFeatures:
- Automatically organizes commits by type (feat, fix, docs, etc.)
- Groups by version tags or dates
- Supports Markdown, JSON, and YAML formats
- Can save directly to file
# Generate PR description for current branch vs main
llmgit ai pr main
# Generate PR description for specified branch
llmgit ai pr feature-branch --base main
# Generate and copy to clipboard
llmgit ai pr main --copyFeatures:
- Summarizes changes clearly
- Includes impact scope and testing suggestions
- Uses formatted PR template structure
- Supports copying to clipboard (macOS, Linux, Windows)
All other Git commands are forwarded directly to native Git:
llmgit status
llmgit log
llmgit branch
# ... etcThe configuration file config.json is automatically saved in ~/.llmgit/. The configuration file contains:
{
"provider": "openai",
"api_key": "sk-xxx",
"model": "gpt-4",
"commit_prompt": "optional custom commit prompt template"
}Note: The configuration file contains sensitive information. Make sure to keep it secure.
The commit_prompt field is optional. If set, it will be used as the template for generating commit messages. The template supports placeholders: {language} and {diff}.
llmgit/
├── main.go # Main program entry
├── Makefile # Build configuration
├── internal/
│ ├── config/ # Configuration management
│ │ └── config.go
│ ├── git/ # Git operation wrapper
│ │ └── git.go
│ └── i18n/ # Internationalization
│ └── i18n.go
├── build/ # Build output directory
├── README.md # English documentation
└── README_CN.md # Chinese documentation
This project is based on the llmhub library and supports multiple large language model providers.
MIT