Skip to content

An intelligent git commit tool that uses Google's Gemini AI to automatically generate professional, meaningful commit messages based on your code changes.

Notifications You must be signed in to change notification settings

LinuxCTRL/smart-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Smart Git Commit Tool

GitHub stars GitHub forks GitHub issues GitHub license Python version

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


✨ Features

🤖 AI-Powered Messages Uses Gemini AI to analyze your changes and generate meaningful commit messages

📝 Conventional Commits Follows industry-standard format (feat:, fix:, docs:, etc.)

🔍 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

🚀 Quick Start

# 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.py

Or install globally:

chmod +x install.sh && ./install.sh
smart-commit  # Use from anywhere!

🎯 Usage

🎮 Interactive Mode (Recommended)

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

⚡ Quick Commands

# 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-run

🌍 Global Usage (After Installation)

smart-commit              # Interactive mode
smart-commit -a           # Auto-stage and commit
smart-commit -a -p        # Auto-stage, commit, and push
smart-commit --dry-run    # Preview mode

💻 Installation

Option 1: Automated Installer (Recommended)

curl -sSL https://raw.githubusercontent.com/LinuxCTRL/smart-commit/refs/heads/master/smart_commit.py | bash

Option 2: Manual Installation

git clone https://github.com/LinuxCTRL/smart-git-commit.git
cd smart-git-commit
chmod +x install.sh
./install.sh

Option 3: Portable Usage

# 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

🔧 Configuration

🔑 API Key Setup

  1. Get your free API key from Google AI Studio

  2. 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"
  3. 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!

🎨 Commit Message Format

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

🛠️ How It Works

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
Loading
  1. 🔍 Change Analysis - Scans git status and diffs
  2. 🧠 Context Building - Gathers file changes, diffs, and commit history
  3. 🤖 AI Generation - Sends context to Gemini AI for message generation
  4. 👤 User Review - Present message for approval/editing
  5. ✅ Git Operations - Stage, commit, and optionally push

🚨 Troubleshooting

🔑 API Key Issues

"No API key found" warning:

  • Set GEMINI_API_KEY environment variable
  • Or use --api-key parameter
  • 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 init if 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

🤝 Contributing

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!

🎯 Ideas for Contributions

  • Support for other AI providers (OpenAI, Claude, Anthropic)
  • Custom commit message templates
  • Git hooks integration
  • Multi-language support
  • VS Code extension
  • GitHub Actions integration

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⭐ Show Your Support

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

🚀 Get Started📖 Documentation🤝 Contribute

About

An intelligent git commit tool that uses Google's Gemini AI to automatically generate professional, meaningful commit messages based on your code changes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published