Generate intelligent git commit messages using your local Ollama instance. No API keys, completely free, and runs offline!
- 🤖 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
pip install ollama-git-commitgit clone https://github.com/himanshu231204/ai-commit.git
cd ai-commit
pip install -e .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
-
Stage your changes:
git add . -
Generate commit message:
ai-commit
-
Review and choose:
y- Accept and commitr- Regenerate messagee- Edit message manuallyn- Cancel
# 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 - CancelIf your Ollama server is running on a different host/port, edit ai_commit.py:
ollama = OllamaClient(base_url="http://192.168.1.100:11434")ollama = OllamaClient(model="codellama") # or "mistral", "llama2", etc.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
AI Commit automatically selects the best available model on your system, prioritizing lighter and faster models for optimal performance.
- phi - Smallest, fastest (Recommended for quick commits)
- mistral - Great balance of speed and quality
- qwen - Fast alternative
- gemma - Google's lightweight model
- codellama - Optimized for code
- llama2 - Reliable but slower
- llama3 - Most powerful but slowest
When you run ai-commit, the tool will:
- Check all installed Ollama models
- Automatically select the lightest/fastest available
- Display which model was chosen
- Generate your commit message
$ ai-commit
╔═══════════════════════════════════════════╗
║ 🤖 AI Commit Message Tool ║
║ Powered by Local Ollama 🦙 ║
╚═══════════════════════════════════════════╝
🔍 Checking Ollama server...
✓ Ollama server is running
Available models (3):
• phi:latest
• mistral:latest
• llama2:latest
✓ Auto-selected: phi:latest
(Prioritizing lighter/faster models)
📊 Changes:
+ 8 lines added
- 0 lines removed
🤖 Generating commit message...For best performance, install a lightweight model:
# Fastest (Recommended)
ollama pull phi
# Good balance
ollama pull mistral
# For code-heavy projects
ollama pull codellamaIf you want to use a specific model, you can set an environment variable:
Windows:
set OLLAMA_MODEL=mistral
ai-commitLinux/Mac:
export OLLAMA_MODEL=mistral
ai-commit$ git add new_feature.py
$ ai-commit
Generated: feat: add user profile management feature$ git add bug_fix.py
$ ai-commit
Generated: fix: resolve null pointer exception in login$ git add README.md
$ ai-commit
Generated: docs: update installation instructionsError: Cannot connect to Ollama
Solution: Start Ollama server with `ollama serve`
Error: No staged changes found
Solution: Stage your changes with `git add <files>`
Error: Model not found
Solution: Pull the model with `ollama pull llama2`
Contributions are what make the open-source community amazing! Any contributions you make are greatly appreciated.
- 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.
This project is licensed under the MIT License - see the LICENSE file for details.
- Ollama - For making local LLMs accessible
- Git - The best version control system
- Python - For being awesome
- You - For using this tool!
- 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
Himanshu Kumar
- 🌐 GitHub: @himanshu231204
- 💼 LinkedIn: himanshu231204
- 🐦 Twitter/X: @himanshu231204
- 📧 Email: [email protected]
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
- PyPI Package: https://pypi.org/project/ollama-git-commit/
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Releases: GitHub Releases
- Changelog: CHANGELOG.md
Give a ⭐️ if this project helped you!
Made with ❤️ by Himanshu Kumar
| Resource | Link |
|---|---|
| 📦 Install | pip install ollama-git-commit |
| 📖 Docs | GitHub |
| 🐛 Issues | Report Bug |
| 💡 Feature Request | Request Feature |
| 💬 Discussions | Join Discussion |
| ⭐ Star | Star on GitHub |