Skip to main content

Generate AI-powered git commit messages using local Ollama

Project description

๐Ÿค– Ollama Git Commit - AI-Powered Commit Messages

PyPI version PyPI Downloads Python 3.8+ License: MIT GitHub Stars

Generate intelligent git commit messages using your local Ollama instance. No API keys, completely free, and runs offline!


โœจ Features

  • ๐Ÿค– AI-Powered: Uses local Ollama models to generate commit messages
  • ๐Ÿ”’ Privacy First: Everything runs locally, no data sent to external APIs
  • ๐ŸŽฏ Multiple Styles: Conventional commits, semantic, or detailed formats
  • ๐Ÿ’ฐ Free: No API costs, uses your local Ollama instance
  • โšก Fast: Quick generation with local models
  • ๐ŸŽจ Interactive: Review, regenerate, or edit messages before committing
  • ๐ŸŒ Offline: Works completely offline

๐Ÿ“ฆ Installation

From PyPI (Recommended)

pip install ollama-git-commit

From Source

git clone https://github.com/himanshu231204/ai-commit.git
cd ai-commit
pip install -e .

๐Ÿ“‹ Prerequisites

Before using Ollama Git Commit, you need:

  1. Python 3.8+

    python --version
    
  2. Git

    git --version
    
  3. Ollama - Install Ollama

    # Install Ollama (macOS/Linux)
    curl -fsSL https://ollama.ai/install.sh | sh
    
    # Pull a model (e.g., llama2)
    ollama pull llama2
    
    # Start Ollama server
    ollama serve
    

๐Ÿ’ก Usage

Basic Usage

  1. Stage your changes:

    git add .
    
  2. Generate commit message:

    ai-commit
    
  3. Review and choose:

    • y - Accept and commit
    • r - Regenerate message
    • e - Edit message manually
    • n - Cancel

Example Workflow

# Make some changes to your code
echo "print('Hello World')" > hello.py

# Stage the changes
git add hello.py

# Generate AI commit message
ai-commit

# Output:
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘         ๐Ÿค– AI Commit Message Tool         โ•‘
โ•‘      Powered by Local Ollama ๐Ÿฆ™           โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ” Checking Ollama server...
โœ“ Ollama server is running

๐Ÿ“Š Changes:
  + 1 lines added
  - 0 lines removed

๐Ÿค– Generating commit message...

Generated Commit Message:
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
feat: add hello world script
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

Options:
  y - Accept and commit
  r - Regenerate message
  e - Edit message
  n - Cancel

โš™๏ธ Configuration

Custom Ollama Server

If your Ollama server is running on a different host/port, edit ai_commit.py:

ollama = OllamaClient(base_url="http://192.168.1.100:11434")

Change AI Model

ollama = OllamaClient(model="codellama")  # or "mistral", "llama2", etc.

Commit Message Styles

The tool supports three commit message styles:

  1. Conventional Commits (default):

    feat(auth): add user login functionality
    
  2. Semantic:

    Add user login functionality
    
  3. Detailed:

    Add user authentication system
    
    - Implement JWT-based authentication
    - Add login and logout endpoints
    - Create user session management
    

๐ŸŽจ Supported Ollama Models

Any Ollama model works, but these are recommended:

  • llama2 - Best overall performance
  • codellama - Optimized for code
  • mistral - Fast and efficient
  • phi - Lightweight option
  • llama3 - Latest and most powerful
# Pull and use different models
ollama pull codellama
ollama pull mistral
ollama pull phi

๐Ÿ“ Examples

Example 1: Adding a New Feature

$ git add new_feature.py
$ ai-commit

Generated: feat: add user profile management feature

Example 2: Bug Fix

$ git add bug_fix.py
$ ai-commit

Generated: fix: resolve null pointer exception in login

Example 3: Documentation

$ git add README.md
$ ai-commit

Generated: docs: update installation instructions

๐Ÿ› Troubleshooting

Ollama Not Running

Error: Cannot connect to Ollama
Solution: Start Ollama server with `ollama serve`

No Staged Changes

Error: No staged changes found
Solution: Stage your changes with `git add <files>`

Model Not Found

Error: Model not found
Solution: Pull the model with `ollama pull llama2`

๐Ÿค Contributing

Contributions are what make the open-source community amazing! Any contributions you make are greatly appreciated.

How to Contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (when available)
  5. Commit using ai-commit! ๐Ÿ˜„
  6. Push to your branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

See CONTRIBUTING.md for detailed guidelines.


๐Ÿ“„ License

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


๐Ÿ™ Acknowledgments

  • Ollama - For making local LLMs accessible
  • Git - The best version control system
  • Python - For being awesome
  • You - For using this tool!

๐Ÿ—บ๏ธ Roadmap

  • Initial release on PyPI
  • Configuration file support (.ai-commit.yml)
  • More commit message formats
  • Interactive model selection
  • Emoji support in commits ๐ŸŽ‰
  • Multiple language support
  • Git hooks integration
  • VSCode extension
  • Custom prompt templates
  • Commit message history
  • Auto-detect commit type from files
  • Batch commit support
  • Integration with GitHub CLI

๐Ÿ‘จโ€๐Ÿ’ป Author

Himanshu Kumar


๐Ÿ’– Support

If you find this project helpful, please consider:

  • โญ Starring the repository
  • ๐Ÿ› Reporting bugs
  • ๐Ÿ’ก Suggesting new features
  • ๐Ÿ”€ Contributing code
  • โ˜• Buy me a coffee
  • ๐Ÿ’ Sponsor on GitHub

๐Ÿ“Š Stats

GitHub stars GitHub forks GitHub watchers PyPI downloads


๐Ÿ”— Links


๐ŸŒŸ Star History

Star History Chart


๐Ÿ“ฃ Show Your Support

Give a โญ๏ธ if this project helped you!


Made with โค๏ธ by Himanshu Kumar


๐Ÿš€ Quick Links

Resource Link
๐Ÿ“ฆ Install pip install ollama-git-commit
๐Ÿ“– Docs GitHub
๐Ÿ› Issues Report Bug
๐Ÿ’ก Feature Request Request Feature
๐Ÿ’ฌ Discussions Join Discussion
โญ Star Star on GitHub

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ollama_git_commit-0.1.3.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ollama_git_commit-0.1.3-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file ollama_git_commit-0.1.3.tar.gz.

File metadata

  • Download URL: ollama_git_commit-0.1.3.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ollama_git_commit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 34e06840ab0f96161251e01853d3b5e99888a95755d58d48e6f9628b928623f1
MD5 3651c8db79a365c30525d5fe8b8779c9
BLAKE2b-256 33f3461f70acf0779fc22a3d91c3ba01ddf8c1fdc0e9b1bf3a42e6b2965c5da1

See more details on using hashes here.

File details

Details for the file ollama_git_commit-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for ollama_git_commit-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 497cd4eafb510d4cebd1462d8b9ac7d5c2f95e5bc96d5ff338daf3847d53905c
MD5 419c28fb94e99e3ee72c35e52d8ecbf4
BLAKE2b-256 73248cfa524550e05654242ad7b268cd503da3e9b26839609c5d0404d62983a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page