Skip to content

A git cli which enhanced by llm ability, developed using Golang,

Notifications You must be signed in to change notification settings

gotoailab/llmgit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[中文介绍] | [Join Discord]

llmgit - AI-Enhanced Git Tool

llmgit is a Git enhancement tool powered by large language models, providing an intelligent Git operation experience.

Features

  • 🤖 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

Installation

Build from Source

cd projects/llmgit
make build
# The binary will be in build/llmgit

Or use Go directly:

go build -o build/llmgit

Install to System

make install
# Or manually copy build/llmgit to a directory in your PATH

Initialization

Before 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-turbo

Supported providers include:

  • openai - OpenAI
  • deepseek - DeepSeek
  • qwen - Qwen (通义千问)
  • claude - Anthropic Claude
  • gemini - Google Gemini
  • And more (run llmgit ai providers to see the full list)

Usage

Language Selection

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 commit

Supported languages:

  • en (default) - English
  • zh / cn / chinese - Chinese

List Supported Providers

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

AI Commit Message Generation

# 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-verify

Commit 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 feature
  • fix - A bug fix
  • docs - Documentation only changes
  • style - Code style changes (formatting, etc.)
  • refactor - Code refactoring
  • perf - Performance improvements
  • test - Adding or updating tests
  • build - Build system or external dependencies
  • ci - CI configuration changes
  • chore - Other changes that don't modify src or test files
  • revert - Reverts a previous commit

Scope is optional and can be omitted.

Commit Language Options:

  • en (default) - English
  • zh / 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 diff

If no custom prompt is set, the default template will be used.

AI Code Review

# Review the latest commit
llmgit ai review

# Review a specific commit
llmgit ai review HEAD~1
llmgit ai review abc123

AI Diff Explanation

# 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

Auto-generate CHANGELOG

# 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 yaml

Features:

  • 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

PR/MR Description Generation

# 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 --copy

Features:

  • Summarizes changes clearly
  • Includes impact scope and testing suggestions
  • Uses formatted PR template structure
  • Supports copying to clipboard (macOS, Linux, Windows)

Other Git Commands

All other Git commands are forwarded directly to native Git:

llmgit status
llmgit log
llmgit branch
# ... etc

Configuration

The 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}.

Project Structure

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

Development

This project is based on the llmhub library and supports multiple large language model providers.

License

MIT

About

A git cli which enhanced by llm ability, developed using Golang,

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published