Never write commit messages again! ๐
An intelligent git commit tool that uses Google's Gemini AI to automatically generate professional, meaningful commit messages based on your code changes.
๐ Quick Start โข ๐ Features โข ๐ป Installation โข ๐ฏ Usage โข ๐ง Configuration
|
๐ค AI-Powered Messages Uses Gemini AI to analyze your changes and generate meaningful commit messages ๐ Conventional Commits
Follows industry-standard format ( ๐ Smart Analysis Analyzes file changes, diffs, and recent commit history for context |
๐ฌ Interactive Mode Review and edit AI suggestions before committing ๐ Batch Operations Stage, commit, and push in one command ๐ก๏ธ Fallback Mode Works perfectly without AI when API key is not available |
# 1. Clone the repository
git clone https://github.com/LinuxCTRL/smart-git-commit.git
cd smart-git-commit
python3 -m venv .venv
source .venv/bin/activate
# 2. Install dependencies
pip install requests
# 3. Set up your API key (optional but recommended)
export GEMINI_API_KEY="your-api-key-here"
# 4. Start using it!
python3 smart_commit.pyOr install globally:
chmod +x install.sh && ./install.sh
smart-commit # Use from anywhere!python3 smart_commit.py๐บ See example output
๐ Analyzing repository changes...
๐ Changes Summary:
โ Added: 2 files
โ๏ธ Modified: 3 files
๐ค Generating commit message...
๐ก Suggested commit message:
feat: add user authentication system
โ Use this message? (Y/n/e): y
โ
Staged all changes
โ
Committed successfully: feat: add user authentication system
โ Push to remote? (y/N): y
โ
Pushed to origin
# Auto-stage and commit with AI message
python3 smart_commit.py -a
# Auto-stage, commit, and push
python3 smart_commit.py -a -p
# Use custom message
python3 smart_commit.py -a -m "fix: resolve authentication bug"
# Preview what would happen (dry run)
python3 smart_commit.py --dry-runsmart-commit # Interactive mode
smart-commit -a # Auto-stage and commit
smart-commit -a -p # Auto-stage, commit, and push
smart-commit --dry-run # Preview modecurl -sSL https://raw.githubusercontent.com/LinuxCTRL/smart-commit/refs/heads/master/smart_commit.py | bashgit clone https://github.com/LinuxCTRL/smart-git-commit.git
cd smart-git-commit
chmod +x install.sh
./install.sh# Download just the main script
curl -O https://raw.githubusercontent.com/LinuxCTRL/smart-commit/refs/heads/master/smart_commit.py
pip install requests
python3 smart_commit.py-
Get your free API key from Google AI Studio
-
Set environment variable:
# Add to ~/.bashrc or ~/.zshrc export GEMINI_API_KEY="your-api-key-here" # Or set temporarily export GEMINI_API_KEY="your-key"
-
Or pass directly:
python3 smart_commit.py --api-key "your-key"
๐ก Pro Tip: The tool works great even without an API key using intelligent fallback logic!
Generated messages follow Conventional Commits specification:
| Type | Description | Example |
|---|---|---|
feat |
New features | feat: add user dashboard |
fix |
Bug fixes | fix: resolve login issue |
docs |
Documentation | docs: update API guide |
style |
Code formatting | style: fix indentation |
refactor |
Code refactoring | refactor: optimize queries |
test |
Tests | test: add unit tests |
chore |
Maintenance | chore: update dependencies |
graph LR
A[Analyze Changes] --> B[Build Context]
B --> C[AI Generation]
C --> D[User Review]
D --> E[Commit & Push]
B --> F[Fallback Mode]
F --> D
- ๐ Change Analysis - Scans git status and diffs
- ๐ง Context Building - Gathers file changes, diffs, and commit history
- ๐ค AI Generation - Sends context to Gemini AI for message generation
- ๐ค User Review - Present message for approval/editing
- โ Git Operations - Stage, commit, and optionally push
๐ API Key Issues
"No API key found" warning:
- Set
GEMINI_API_KEYenvironment variable - Or use
--api-keyparameter - Tool works in fallback mode without AI
API errors:
- Verify your API key is valid
- Check internet connection
- Ensure you haven't exceeded API quotas
๐๏ธ Git Repository Issues
"Not a git repository" error:
- Make sure you're in a git repository
- Run
git initif needed - Check you have proper git permissions
๐ Python Issues
Import errors:
- Install dependencies:
pip install requests - Ensure Python 3.7+ is installed
- Check your Python PATH
We love contributions! Here are some ways to help:
- ๐ Report bugs - Found an issue? Let us know!
- ๐ก Suggest features - Have ideas? We'd love to hear them!
- ๐ง Submit PRs - Code contributions are welcome!
- ๐ Improve docs - Help make the documentation better!
- Support for other AI providers (OpenAI, Claude, Anthropic)
- Custom commit message templates
- Git hooks integration
- Multi-language support
- VS Code extension
- GitHub Actions integration
This project is licensed under the MIT License - see the LICENSE file for details.
If this tool helps you, please consider:
- โญ Starring the repository
- ๐ฆ Sharing on social media
- ๐ฌ Telling your friends and colleagues
Made with โค๏ธ by developers, for developers