Skip to content

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

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors