Git Generator is a professional CLI tool that uses AI to generate high-quality Git commit messages based on your staged changes. It analyzes your diff and creates conventional commit messages that follow best practices.
Test bullet points formatting in commit messages.
- 🤖 AI-Powered: Uses Google Gemini API for intelligent commit message generation
- 📝 Conventional Commits: Follows conventional commit standards by default
- 🔍 Smart Diff Analysis: Intelligently parses and chunks large diffs
- 🎨 Multiple Styles: Support for conventional, simple, and detailed commit message styles
- 🔧 Configurable: Extensive configuration options via YAML config file
- 🚀 Fast & Reliable: Built with Go for performance and reliability
- 📊 Language Detection: Automatically detects programming languages in changes
- 🔄 Interactive Mode: Preview and edit commit messages before applying
- 📋 Dry Run: Preview commit messages without applying them
- Go 1.21 or later
- Git repository
- Google Gemini API key
git clone https://github.com/nguyendkn/git-generator.git
cd git-generator
go build -o git-generator cmd/git-generator/main.gogo install github.com/nguyendkn/git-generator/cmd/git-generator@latest-
Initialize configuration:
git-generator init
-
Set your Gemini API key:
git-generator config set-api-key YOUR_API_KEY
Or set the environment variable:
export GEMINI_API_KEY=your_api_key_here -
Generate and apply commit message (auto-stages changes):
git-generator generate
Note: The
generatecommand automatically runsgit add .to stage all changes before generating the commit message. Use--no-addflag to skip auto-staging if you want to manually control which files are staged.
# Generate commit message (auto-stages all changes)
git-generator generate
# Preview without committing (dry-run)
git-generator generate --dry-run
# Generate without auto-staging changes
git-generator generate --no-add
# Generate multiple options
git-generator generate --multiple
# Use different style
git-generator generate --style simple
# Show repository status
git-generator status
# Show current configuration
git-generator config show--style, -s: Commit message style (conventional,simple,detailed)--dry-run, -d: Preview the commit message without applying it--staged, -S: Use staged changes (default: true)--multiple, -m: Generate multiple commit message options--no-add: Skip automatic staging of changes (git add .)
Auto-staging Feature: By default, the
generatecommand automatically runsgit add .to stage all changes before generating the commit message. This streamlines the workflow by eliminating the need to manually stage files. Use the--no-addflag if you prefer to manually control which files are staged.
show: Display current configurationset-api-key [key]: Set the Gemini API key
Git Generator uses a YAML configuration file located at ~/.git-generator/git-generator.yaml.
# Git Generator Configuration
gemini:
# Get your API key from: https://makersuite.google.com/app/apikey
api_key: "your_api_key_here"
model: "gemini-1.5-flash"
temperature: 0.3
max_tokens: 1000
git:
max_diff_size: 10000
include_staged: true
ignore_files:
- "*.log"
- "*.tmp"
- "node_modules/*"
- ".git/*"
- "vendor/*"
- "target/*"
- "build/*"
- "dist/*"
output:
style: "conventional" # conventional, simple, detailed
max_lines: 100
dry_run: falseapi_key: Your Google Gemini API key (required)model: Gemini model to use (default: "gemini-1.5-flash")temperature: AI creativity level 0.0-2.0 (default: 0.3)max_tokens: Maximum response length (default: 1000)
max_diff_size: Maximum diff size to process (default: 10000)include_staged: Include staged changes (default: true)ignore_files: File patterns to ignore
style: Default commit message style (default: "conventional")max_lines: Maximum lines in output (default: 100)dry_run: Default to dry-run mode (default: false)
Follows the Conventional Commits specification:
feat(auth): add JWT authentication
Implement JWT-based authentication system with refresh token support.
Includes middleware for route protection and token validation.
Closes #123
Concise, single-line commit messages:
Add user authentication system
Comprehensive commit messages with full context:
Implement comprehensive user authentication system
This commit introduces a complete authentication system including:
- JWT token generation and validation
- Refresh token mechanism
- Password hashing with bcrypt
- Session management
- Route protection middleware
The system supports both login and registration workflows
and includes proper error handling and validation.
Files changed:
- auth/jwt.go: JWT token handling
- auth/middleware.go: Authentication middleware
- handlers/auth.go: Authentication endpoints
- models/user.go: User model updates
Closes #123
Fixes #124
# Stage your changes
git add src/auth.go src/middleware.go
# Generate and apply commit message
git-generator generate
# Output: feat(auth): implement JWT authentication systemgit-generator generate --dry-runOutput:
Preview (dry-run mode):
Commit Message:
feat(auth): implement JWT authentication system
Implement JWT-based authentication with middleware support.
Includes token validation and refresh mechanisms.
Changes Summary:
2 added files with 150 additions and 0 deletions. Languages: Go (2)
Languages:
- Go: 2 files
File Changes:
1. added: src/auth.go (75+, 0-)
2. added: src/middleware.go (75+, 0-)
git-generator generate --multipleOutput:
Generated commit message options:
1. feat(auth): implement JWT authentication system
2. add: JWT authentication and middleware
3. feat: implement comprehensive authentication system
Add JWT-based authentication with token validation,
refresh mechanisms, and route protection middleware.
- Visit Google AI Studio
- Create a new API key
- Copy the key
Option 1: Using the CLI
git-generator config set-api-key YOUR_API_KEYOption 2: Environment Variable
export GEMINI_API_KEY=your_api_key_hereOption 3: Configuration File
Edit ~/.git-generator/git-generator.yaml and add:
gemini:
api_key: "your_api_key_here"git clone https://github.com/nguyendkn/git-generator.git
cd git-generator
go mod download
go build -o git-generator cmd/git-generator/main.gogo test ./...git-generator/
├── cmd/git-generator/ # Main CLI application
├── internal/ # Internal packages
│ ├── ai/ # Gemini API integration
│ ├── config/ # Configuration management
│ ├── diff/ # Diff processing and chunking
│ ├── generator/ # Core generation logic
│ ├── git/ # Git operations
│ └── logger/ # Logging utilities
├── pkg/types/ # Public types and interfaces
└── README.md
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Conventional Commits for the commit message standard
- Google Gemini for the AI capabilities
- Cobra for the CLI framework
- Viper for configuration management