git-commit-sage 🧙♂️
A smart Git commit message generator using AI, powered by Together.ai.
📦 Installation
Option 1: Install from crates.io (Recommended)
# Install using cargo (Rust's package manager)
# Verify installation
Option 2: Install from source
# Clone the repository
# Install using cargo
# Verify installation
Requirements
- Rust 1.70 or later (install via rustup)
- Git 2.0 or later
- Together.ai API key (get one at together.ai)
🧙♂️ Git Commit Sage
🤖 Your AI-powered companion for writing perfect conventional commit messages
✨ Features
- 🎯 Generates conventional commit messages from your git diff
- 🔄 Supports multiple AI providers through a flexible trait system
- ⚡ Built-in support for Together.ai's Mixtral-8x7B model
- 🛠️ Configurable via TOML and environment variables
- 📦 Available as both a CLI tool and a Rust library
🎯 Getting Started
First Time Setup
# 1. Initialize your repository (if not already done)
# 2. Create your .env file with your API key
# 3. Stage ALL your files
()
# 4. Create the initial commit manually (required for first commit only)
)
)
# 5. For subsequent changes, stage and use git-commit-sage
)
Quick Start Guide
-
Stage your changes
# Always stage ALL related changes before generating a message # OR # Verify what's staged -
Generate a commit message
) -
Review and commit
# Option 1: Manual commit with the suggested message # Option 2: Auto-commit (uses the staged changes)
Best Practices
-
Stage Related Changes Together
- Always stage ALL related files before generating a message
- Use
git statusto verify what's staged - The better your staging, the better the commit message
-
Review the Diff
# See what changes will be included in the message generation # Or use git's built-in diff tool -
Adjust Message Quality
# Use lower temperature for more focused messages # Use higher temperature for more creative messages -
Working with Multiple Changes
# Bad: Staging unrelated changes # Good: Stage related changes together
🔧 Configuration
- Create a
.envfile or set your environment variables:
TOGETHER_API_KEY=your_api_key_here
- (Optional) Create a
commit-sage.tomlin your project root or home directory:
💻 Usage
CLI Usage
# Generate a commit message for staged changes
)
# Show the diff being analyzed (useful for debugging)
# Generate and automatically commit
)
# Specify custom temperature
)
)
# Use a different API key
)
Library Usage
Add to your Cargo.toml:
[]
= "0.1.0"
Example implementation:
use ;
use async_trait;
// Use the built-in Together.ai provider
let provider = new;
// Or implement your own provider
;
🔄 Common Workflows
Feature Development
# Start a new feature branch
# Make your changes and stage them
)
# Make more changes
)
# Final changes with auto-commit
)
Bug Fixing
# Create a bug fix branch
# Fix the bug and stage changes
)
)
Refactoring
# Start refactoring
# Stage partial changes
)
# Stage more changes
)
Documentation Updates
# Update docs
)
# Update examples
)
Project Maintenance
# Update dependencies
)
# Configure CI/CD
Working with Multiple Changes
# Stage and commit related changes together
)
# Stage and commit unrelated changes separately
)
)
🚨 Troubleshooting
Common Issues
-
Error: NoChanges
This can happen in two cases:
- No changes are staged (run
git addfirst) - This is the initial commit (you need at least one commit for diff comparison)
For initial commits, you should create the first commit manually:
- No changes are staged (run
-
API Key Issues
Make sure your Together.ai API key is:
- Correctly set in
.envor environment variables - Valid and has sufficient credits
- Not expired or revoked
- Correctly set in
-
No Configuration File
This is normal! The tool works with sensible defaults, but you can create a config file:
🌟 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with Together.ai
- Uses the Mixtral-8x7B model by Mistral AI
- Inspired by the Conventional Commits specification