Generate AI-powered git commit messages using local Ollama
Project description
๐ค Ollama Git Commit - AI-Powered Commit Messages
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:
-
Python 3.8+
python --version -
Git
git --version -
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
-
Stage your changes:
git add .
-
Generate commit message:
ai-commit
-
Review and choose:
y- Accept and commitr- Regenerate messagee- Edit message manuallyn- 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:
-
Conventional Commits (default):
feat(auth): add user login functionality -
Semantic:
Add user login functionality -
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:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (when available)
- Commit using ai-commit! ๐
- Push to your branch (
git push origin feature/amazing-feature) - 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
- ๐ GitHub: @himanshu231204
- ๐ผ LinkedIn: himanshu231204
- ๐ฆ Twitter/X: @himanshu231204
- ๐ง Email: himanshu231204@gmail.com
๐ 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
๐ Links
- PyPI Package: https://pypi.org/project/ollama-git-commit/
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Releases: GitHub Releases
- Changelog: CHANGELOG.md
๐ Star History
๐ฃ 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34e06840ab0f96161251e01853d3b5e99888a95755d58d48e6f9628b928623f1
|
|
| MD5 |
3651c8db79a365c30525d5fe8b8779c9
|
|
| BLAKE2b-256 |
33f3461f70acf0779fc22a3d91c3ba01ddf8c1fdc0e9b1bf3a42e6b2965c5da1
|
File details
Details for the file ollama_git_commit-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ollama_git_commit-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
497cd4eafb510d4cebd1462d8b9ac7d5c2f95e5bc96d5ff338daf3847d53905c
|
|
| MD5 |
419c28fb94e99e3ee72c35e52d8ecbf4
|
|
| BLAKE2b-256 |
73248cfa524550e05654242ad7b268cd503da3e9b26839609c5d0404d62983a4
|