AI-powered Git assistant CLI tool.
- AI-generated commit messages
- Automated sync workflow with gate confirmations
- Multi-provider support (OpenAI, Anthropic, Ollama)
npm install -g @zdc/smartgit# Interactive menu (no arguments)
smartgit
# Configure your API key
smartgit config
# Commit changes with AI-generated message
aigit commit
# Full workflow: sync, commit, and push
aigit push| Command | Description |
|---|---|
smartgit |
Interactive menu - Select action from list |
smartgit commit |
Analyze changes and create commit with AI-generated message |
smartgit push |
Full workflow: sync, commit, and push changes |
| Option | Description |
|---|---|
-y, --yes |
Skip non-dangerous confirmations |
-v, --verbose |
Show verbose output |
--dry-run |
Preview execution without making changes |
Configuration file location: ~/.aigit/config.json
{
"ai": {
"provider": "openai",
"baseURL": "https://api.openai.com/v1",
"apiKey": "sk-xxx",
"model": "gpt-4o-mini"
},
"git": {
"defaultBranch": "main"
},
"commit": {
"language": "zh" // "zh" for Chinese, "en" for English
},
"filter": {
"ignoreWhitespace": true,
"ignoreComments": true,
"ignoreBuildArtifacts": true,
"mergeCancelingOps": true,
"maxListItems": 7
},
"confirm": {
"level": "interactive"
},
"mr": {
"enabled": true, // Enable MR link generation after push
"platform": "auto" // "auto" | "github" | "gitlab"
}
}| Field | Description |
|---|---|
ai.provider |
AI provider: openai, anthropic, or ollama |
ai.apiKey |
Your API key (sk-xxx for OpenAI, sk-ant-xxx for Anthropic) |
ai.baseURL |
API base URL (default depends on provider) |
ai.model |
Model name (default: claude-sonnet-4-20250514 for Anthropic, gpt-4o-mini for OpenAI) |
git.defaultBranch |
Your default branch name (default: main) |
commit.language |
Commit message language: zh (Chinese) or en (English) |
mr.enabled |
Enable MR/PR link generation after push (default: true) |
mr.platform |
Git platform: auto, github, or gitlab |
<type>: <description>
- 1. <change item 1>
- 2. <change item 2>
- 3. <change item 3>
feat- New featurefix- Bug fixdocs- Documentation changesstyle- Code style changes (formatting)refactor- Code refactoringperf- Performance improvementstest- Test changeschore- Build/config changes
feat: 添加用户认证模块
- 1. 新增登录页面和表单验证
- 2. 添加 JWT token 生成逻辑
- 3. 集成 OAuth2 第三方登录
feat: add user authentication module
- 1. Add login page with form validation
- 2. Add JWT token generation logic
- 3. Integrate OAuth2 third-party login
After a successful aigit push, the tool will automatically generate and display a Merge Request (or Pull Request) link.
- GitHub - Creates PR link with
?expand=1to auto-expand description - GitLab - Creates MR link with pre-filled source and target branches
$ smartgit push
✓ Commit created
✓ Changes pushed to remote
┌──────────────────────────────────────────────┐
│ Create Merge Request │
│ │
│ https://github.com/jangze/smart-git/ │
│ compare/main...feature-auth?expand=1 │
└──────────────────────────────────────────────┘To disable MR link generation:
{
"mr": {
"enabled": false
}
}To specify a platform manually:
{
"mr": {
"enabled": true,
"platform": "github"
}
}- Stage all changes (
git add .) - Generate commit message using AI
- Allow user to edit message
- Create commit
- Stage all changes (
git add .) - Check remote branch status → gate confirmation
- Check local master sync status → gate confirmation
- Check if current branch includes latest master → gate confirmation
- Generate commit message using AI
- Allow user to edit message
- Create commit
- Push to remote
MIT