Skip to content

Latest commit

 

History

History
127 lines (85 loc) · 2.67 KB

File metadata and controls

127 lines (85 loc) · 2.67 KB

GenCommit

A Go-based tool that generates intelligent commit messages using Ollama's deepseek-r1:8b model by analyzing git diffs.

Features

  • 🤖 Uses local Ollama service with deepseek-r1:8b model
  • 📝 Generates commit messages based on actual code changes
  • 🎯 Limits commit messages to maximum 20 words
  • 🚀 Simple command: just run gencommit
  • 🔍 Automatically detects staged and unstaged changes

Prerequisites

  1. Go 1.22+ installed on your system
  2. Ollama running locally with deepseek-r1:8b model downloaded
  3. Git repository initialized

Installation

Option 1: Install to system (requires sudo)

make install

Option 2: Install to user directory (recommended)

make install-local

Note: If using install-local, ensure ~/.local/bin is in your PATH:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Manual Installation

# Build the binary
go build -o gencommit main.go

# Move to a directory in your PATH
sudo cp gencommit /usr/local/bin/
# OR
cp gencommit ~/.local/bin/

Usage

  1. Navigate to a git repository

    cd /path/to/your/git/repo
  2. Make some changes to your code

  3. Stage your changes (optional)

    git add .
  4. Generate a commit message

    gencommit
  5. Commit with the generated message

    git commit -m "your generated message here"

How it Works

  1. The tool checks if you're in a git repository
  2. It analyzes the git diff (staged changes first, then unstaged)
  3. Sends the diff to your local Ollama service using the deepseek-r1:8b model
  4. Generates a concise commit message (max 20 words)
  5. Displays the message and provides the git commit command

Configuration

The tool connects to Ollama at http://localhost:11434 by default. If you need to change this, modify the URL in the generateCommitMessage function in main.go.

Troubleshooting

"Not in a git repository"

  • Ensure you're in a directory with a .git folder
  • Run git init if you haven't initialized the repository

"Failed to connect to Ollama"

  • Make sure Ollama is running: ollama serve
  • Verify the deepseek-r1:8b model is downloaded: ollama list
  • Check if Ollama is accessible at http://localhost:11434

"No changes detected"

  • Stage your changes with git add . or make new changes
  • The tool checks both staged and unstaged changes

Development

# Get dependencies
make deps

# Build locally
make build

# Test locally
make run

# Clean build artifacts
make clean

License

This project is open source and available under the MIT License.