@cherry-min/git-genius
v0.1.0
Published
AI-powered Git CLI assistant
Downloads
95
Readme
Git Genius (gg)
An AI-powered Git CLI assistant that helps developers understand and manage their Git repositories intelligently.
Features
- 🤖 AI-powered analysis of Git changes and conflicts
- 📊 Intelligent summaries of branches and commits
- ⚔️ Conflict resolution guidance
- 📝 Commit explanations with AI insights
- 💡 Smart suggestions for next steps
- 🎨 Beautiful CLI output with colors and tables
Installation
npm install -g git-geniusOr from source:
git clone <repository>
cd git-genius
npm install
npm run build
npm linkUsage
Commands
gg summary
Generate a summary of branch or commit changes.
# Summarize current branch compared to main
gg summary
# Summarize current branch compared to specific branch
gg summary -b develop
# Summarize specific commit
gg summary -c a1b2c3dgg fix-conflict
Analyze merge conflicts and generate AI-powered fix suggestions with interactive resolution workflow.
gg fix-conflictWhen conflicts are detected, the tool will:
- Show a list of conflicted files
- Analyze each conflict with AI
- Provide fix suggestions
- Offer interactive options to mark as resolved, get more details, or skip
gg explain-commit <hash>
Explain a specific commit with detailed analysis.
gg explain-commit a1b2c3dgg suggest
Get AI-powered suggestions for next steps based on your repository state.
gg suggestThe AI analyzes:
- Current branch and remote state
- Staged and unstaged changes
- Recent commit history
- Merge conflicts
- And provides actionable recommendations
Configuration
Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| OPENAI_API_KEY | OpenAI API key for AI features | Required |
| OPENAI_MODEL | OpenAI model to use | gpt-3.5-turbo |
| OPENAI_BASE_URL | Custom OpenAI-compatible API endpoint | Optional |
Example Configuration
# Set your OpenAI API key
export OPENAI_API_KEY=\"your-api-key-here\"
# Optional: Use a different model
export OPENAI_MODEL=\"gpt-4\"
# Optional: Use custom endpoint (e.g., Azure OpenAI)
export OPENAI_BASE_URL=\"https://your-resource.openai.azure.com/\"Development
Setup
git clone <repository>
cd git-genius
npm installBuild
npm run buildDevelopment Mode
npm run dev -- <command>
# Example:
npm run dev -- summaryRunning Tests
npm testArchitecture
src/
├── index.ts # CLI entry point
├── commands/ # Command implementations
│ ├── summary.ts # Branch/commit summaries
│ ├── fixConflict.ts # Conflict resolution
│ ├── explainCommit.ts # Commit explanations
│ └── suggest.ts # AI suggestions
├── core/ # Core functionality
│ ├── gitUtils.ts # Git operations wrapper
│ └── aiClient.ts # AI API client
└── utils/
└── logger.ts # CLI output formattingAI Prompt Design
The tool uses carefully crafted prompts for different scenarios:
- Change Summaries: Focus on high-level impact and purpose
- Commit Explanations: Deep dive into technical changes and implications
- Conflict Resolution: Step-by-step resolution guidance
- Next Steps: Context-aware workflow suggestions
Prompt templates can be customized in src/core/aiClient.ts.
Examples
Analyzing a Feature Branch
# On your feature branch
gg summary -b main
# See what the AI suggests
gg suggest
# Follow the suggestions, then check again
gg suggestResolving Merge Conflicts
# After a merge with conflicts
gg fix-conflict
# Follow the interactive workflow
# For each conflict, AI provides:
# - Analysis of the conflict
# - Suggested resolution
# - Detailed instructions if neededUnderstanding Commit History
# Explain recent commits
gg explain-commit HEAD
gg explain-commit HEAD~1
gg explain-commit abc1234Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT License - see LICENSE for details.
Support
Made with ❤️ and AI
