DEV Community

Jason
Jason

Posted on

Git AI CLI AI-Powered Git Commit Assistant

Project Overview

Git AI CLI is a powerful AI-driven Git assistant that intelligently generates commit messages, analyzes code changes, and automatically generates project reports. The latest v2.0.0 version is rewritten in Rust, offering better performance and stability.

πŸš€ Quick Start

Installation

npm install -g @dongowu/git-ai-cli
Enter fullscreen mode Exit fullscreen mode

Basic Usage

# Initialize configuration
git-ai config

# Generate commit messages
git add .
git-ai
Enter fullscreen mode Exit fullscreen mode

✨ Core Features

πŸ€– AI-Powered Commits

  • Automatically analyzes code changes to generate professional commit messages
  • Supports multiple AI models (DeepSeek, Ollama, OpenAI, etc.)
  • Intelligently learns project commit styles

πŸ›‘οΈ Copilot Guardian Mode

git-ai --copilot
Enter fullscreen mode Exit fullscreen mode
  • Deep code impact analysis
  • Risk detection and testing recommendations
  • Change impact scope assessment

πŸ“Š Smart Reporting

# Generate weekly reports
git-ai report

# Generate release notes based on tags
git-ai report --from-last-tag
git-ai report --from-tag v1.0.0 --to-ref v2.0.0
Enter fullscreen mode Exit fullscreen mode

βš™οΈ Engineering Configuration

Supports project-level configuration file .git-ai.json:

{
  "provider": "deepseek",
  "model": "deepseek-chat",
  "locale": "en",
  "enableFooter": true
}
Enter fullscreen mode Exit fullscreen mode

🎯 Use Cases

Daily Development

git add .
git-ai --copilot
Enter fullscreen mode Exit fullscreen mode

Team Collaboration

# Install Git Hook for seamless integration
git-ai hook install --global
Enter fullscreen mode Exit fullscreen mode

Version Releases

# Generate version change descriptions
git-ai report --from-tag v1.0.0 --to-ref v2.0.0
Enter fullscreen mode Exit fullscreen mode

πŸ”§ Advanced Features

Agent Intelligence

git-ai -a --copilot
Enter fullscreen mode Exit fullscreen mode
  • Smart handling of large files
  • Code impact scope analysis
  • Potential risk detection

Multi-Platform Support

  • Automatic download of platform-specific binaries
  • Supports Windows, macOS, Linux
  • Local model privacy protection

πŸ“‹ Command Reference

Command Description
git-ai Interactive commit
git-ai --copilot Copilot guardian mode
git-ai -a Agent mode
git-ai report Generate reports
git-ai hook install Install Git Hook
git-ai config Configuration management
git-ai -n 3 Generate 3 candidate messages
git-ai -y Skip confirmation and commit directly

🌟 Key Benefits

πŸš€ Performance Optimized

  • Rust-based core for faster execution
  • Reduced memory footprint
  • Quick startup time

πŸ”’ Privacy First

  • Local model support (Ollama)
  • Data never leaves your network
  • Configurable privacy settings

🧠 Context Aware

  • Branch name analysis for relevant commit messages
  • Learning from recent commit history
  • Project-specific style adaptation

πŸ”§ Developer Friendly

  • Seamless Git integration
  • Zero-configuration setup for local models
  • Comprehensive error handling

πŸ› οΈ Supported AI Models

Category Providers Key Features Configuration
Local Privacy Ollama Free, offline, absolute privacy Auto-detection
LM Studio Good compatibility Manual URL input
High-Speed Domestic DeepSeek Best value, excellent coding capability API Key
Tongyi Qianwen Alibaba ecosystem, strong long-text support API Key
Zhipu/Moonshot Leading domestic models API Key
International OpenAI GPT-4o benchmark capability API Key

πŸ“ Configuration Files

.git-ai.json (Project Configuration)

{
  "provider": "deepseek",
  "baseUrl": "https://api.deepseek.com/v1",
  "model": "deepseek-reasoner",
  "agentModel": "deepseek-chat",
  "locale": "en",
  "enableFooter": true
}
Enter fullscreen mode Exit fullscreen mode

.git-aiignore (File Ignore Patterns)

package-lock.json
dist/
*.min.js
*.map
Enter fullscreen mode Exit fullscreen mode

πŸ”„ Git Hook Integration

Automatic Setup

# Project-specific installation
git-ai hook install

# Global installation (all projects)
git-ai hook install --global
Enter fullscreen mode Exit fullscreen mode

Usage with Hooks

git checkout -b feature/awesome-login
# ... write code ...
git add .
git commit  # AI automatically generates: "feat(login): implement awesome login logic"
Enter fullscreen mode Exit fullscreen mode

πŸ› Troubleshooting

Common Issues

1) 401 / API Key Invalid

git-ai config get --json --local
Enter fullscreen mode Exit fullscreen mode

Check environment variables: GIT_AI_API_KEY, DEEPSEEK_API_KEY, OPENAI_API_KEY

2) Diff Truncation

  • Use .git-aiignore to exclude large files
  • Set GIT_AI_MAX_DIFF_CHARS environment variable

3) Agent Fallback to Basic Mode

GIT_AI_DEBUG=1 git-ai -a
Enter fullscreen mode Exit fullscreen mode

πŸ“ˆ Version 2.0.0 Highlights

Technical Improvements

  • Rust Migration: From Node.js/TypeScript to Rust for better performance
  • Automated Releases: Tag-driven CI/CD pipeline
  • Cross-Platform: Multi-architecture binary distribution

New Features

  • Tag-range release description support
  • Enhanced Copilot CLI integration
  • Improved error handling and debugging

πŸ”— Links

πŸ“„ License

Apache 2.0 License


*Enhance your development workflow with AI-powered commit automation and intelligent code analysis

Top comments (0)