🤖 AI-Powered Git Assistant: Commit, Context & Report
🚀 DeepSeek Optimized | 🏠 Ollama Privacy First | 🧠 Context Aware | 🛡️ Copilot Guardian | 📊 AI Reports
中文文档 • Quick Start • Features • Usage • Configuration
git-ai-cli is more than just a commit message generator. It's your AI Development Assistant. It understands your code diffs, recognizes your branch intent, and even writes your weekly reports.
Starting from v2.x, git-ai-cli ships the Rust edition by default (faster, single-binary). Install via npm (it will download the correct platform binary automatically):
npm install -g @dongowu/git-ai-cliThe Rust edition currently includes agent-lite (impact analysis / symbol search). Advanced security/perf analysis is still being ported.
If you need the legacy TypeScript (v1.x), pin the version explicitly.
# 1. Install
npm install -g @dongowu/git-ai-cli
# 2. Initialize (Auto-detects local models or configures API)
git-ai config
# 3. Use
git add .
git-ai- Ollama Zero-Config: Automatically detects locally running Ollama models (like
llama3,deepseek-coder). No manual setup required. Your data never leaves your machine. - DeepSeek/OpenAI: Built-in support for popular API providers with optimized prompts.
- Style Learning: Automatically analyzes your recent 10 commits to mimic your personal tone, format (e.g., emojis), and language style.
- Branch Awareness: Reads your current branch name (e.g.,
feat/user-login,fix/JIRA-123) to generate semantic commits with Issue IDs or scopes.
Evolving from a text generator to a code expert.
- Smart Diff: The Agent analyzes file stats and reads only the critical diffs to reduce truncation and token usage on large refactors.
- Impact Analysis: Changing a core API? The Agent proactively searches your codebase (
git grep) to find usages and warns you about potential breaking changes in the commit body. - Git Flow Guard: Automatically enables deep analysis on
release/*orhotfix/*branches to protect production code.
Dual-layer AI architecture: Professional commit generation + Deep code analysis.
- Code Impact Analysis: Uses GitHub Copilot CLI to deeply analyze the scope and potential risks of code changes
- Risk Detection: Automatically identifies breaking changes, potential bugs, and security vulnerabilities
- Test Recommendations: Intelligently suggests test scenarios and use cases
- Affected Areas: Analyzes which modules and files might be impacted
- Optional Enable: Enable on-demand via
--copilotflag, no forced dependency
- Project Config: Create a
.git-ai.jsonin your project root to share settings (model, prompts) with your team. - Smart Ignore: Use
.git-aiignoreto exclude auto-generated files (likepackage-lock.json) or large files to save tokens and improve accuracy.
- Zero Distraction: After installing the hook, just run
git commit(without-m). AI automatically fills in the message and opens your editor. - Compatibility: Perfectly compatible with existing Git workflows. Supports
git commit --no-verify.
- One-Click Generation:
git-ai reportanalyzes your recent commits. - Value Driven: Transforms fragmented commits into structured reports highlighting "Core Outputs", "Bug Fixes", and "Technical Improvements".
Create this file in your project root to override global settings:
{
"provider": "deepseek",
"baseUrl": "https://api.deepseek.com/v1",
"model": "deepseek-reasoner",
"agentModel": "deepseek-chat",
"locale": "en",
"enableFooter": true
}Notes:
model: base generation modelagentModel: Agent mode (-a) model (pick a tool-capable model; DeepSeek typically usesdeepseek-chat)locale: onlyzh/en- It's recommended to set
apiKeyvia env vars or global config (don't commit keys into the repo)
# Show effective config (includes env overrides)
git-ai config get --json
# Set global config
git-ai config set model deepseek-chat
# Set per-project config (write to .git-ai.json)
git-ai config set agentModel deepseek-chat --local
# List keys + env overrides
git-ai config describeCommon env overrides (higher priority than config files):
GIT_AI_PROVIDER/GIT_AI_BASE_URL/GIT_AI_MODEL/GIT_AI_AGENT_MODELGIT_AI_API_KEY(also supportsDEEPSEEK_API_KEY,OPENAI_API_KEY)GIT_AI_TIMEOUT_MS(request timeout, default 120000)GIT_AI_MAX_DIFF_CHARS(diff truncation length)GIT_AI_MAX_OUTPUT_TOKENS(output token limit)GIT_AI_DEBUG=1(print more error details)
OpenCommit-compatible env vars:
OCO_AI_PROVIDER/OCO_MODEL/OCO_API_KEYOCO_TOKENS_MAX_INPUT/OCO_TOKENS_MAX_OUTPUT
Exclude specific files from AI analysis (syntax similar to .gitignore):
package-lock.json
dist/
*.min.js
Also compatible with OpenCommit's .opencommitignore (both will be read).
1) 401 / Invalid API key
- Check effective config:
git-ai config get --json --local - Make sure env vars aren't overriding your key:
GIT_AI_API_KEY / DEEPSEEK_API_KEY / OPENAI_API_KEY / OCO_API_KEY
2) Diff truncated
- Ignore large files via
.git-aiignore/.opencommitignore - Or set
GIT_AI_MAX_DIFF_CHARS(also supportsOCO_TOKENS_MAX_INPUT)
3) Agent falls back to basic mode
- Set
GIT_AI_DEBUG=1to see the real failure reason (timeout/rate limit/auth, etc.)
git add .
git-aigit add .
git-ai --copilot
# 1. Generate professional commit message with DeepSeek/Ollama
# 2. GitHub Copilot CLI deep code impact analysis
# 3. Display risk warnings and test recommendations
# 4. Confirm and commitOutput Example:
✨ Generated commit message(s):
feat(auth): implement JWT token refresh mechanism
📊 Impact Analysis:
Modified authentication flow to support automatic token refresh
⚠️ Potential Risks:
• Breaking change: Old tokens will be invalidated
• Session management logic needs update
🔗 Affected Areas:
• Login component
• API middleware
• User session store
✅ Test Recommendations:
• Test token expiration handling
• Verify refresh token rotation
• Check concurrent request handling
The smoothest experience. Install once, use forever.
# Install for current project
git-ai hook install
# Or install globally (for all projects)
git-ai hook install --globalThen just run:
git checkout -b feature/awesome-login
# ... write code ...
git add .
git commit # ✨ AI generates "feat(login): implement awesome login logic"Hate writing weekly reports?
# Generate report for this week
git-ai report
# Generate report for the last 30 days
git-ai report --days 30
# Generate feature-focused release notes from latest tag to current ref
git-ai report --from-last-tag
# Generate release notes for a specific tag range (e.g. v1.0.21 -> v2.0.0)
git-ai report --from-tag v1.0.21 --to-ref v2.0.0| Command | Alias | Description |
|---|---|---|
git-ai config |
config |
Initialize Config (Provider, Key, Language) |
git-ai config get |
Show effective config (supports --json / --local) |
|
git-ai config set <key> <value> |
Set config (supports --local / --json) |
|
git-ai config describe |
List config keys and env overrides | |
git-ai |
Interactive generation & commit | |
git-ai --copilot |
Copilot Guardian Mode (Code impact analysis & Risk detection) | |
git-ai -a |
Agent Mode (Deep analysis & Impact check) | |
git-ai -a --copilot |
Ultimate Mode (Agent + Copilot dual protection) | |
git-ai -y |
Skip confirmation and commit directly | |
git-ai -n 3 |
Generate 3 options to choose from | |
git-ai -l en |
Force language (en/zh) | |
git-ai hook install |
Install Git Hook (supports --global) |
|
git-ai report |
Generate AI Report / Release Notes (supports --days / --from-last-tag / --from-tag --to-ref) |
|
git-ai msg |
Generate message only (stdout for scripts) |
Made with ❤️ by git-ai team
🤖 Generated by git-ai 🚀