GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ttpho/git_diff_auto_commit: A Python script that automates the process of generating concise, conventional commit messages for your Git repository changes using an LLM (via Ollama). It can commit all changes at once or commit each file separately, with AI-generated commit messages based on the actual diffs.

BranchesTags
Open more actions menu

Latest commit

 

History

31 Commits
31 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
VERSION
VERSION
 
 
auto_commit.py
auto_commit.py
 
 

Repository files navigation

Overview

auto_commit.py is a Python script that automates the process of generating concise, conventional commit messages for your Git repository changes using an LLM (via Ollama). It can commit all changes at once or commit each file separately, with AI-generated commit messages based on the actual diffs.

Features

  • AI-generated commit messages: Uses an LLM to analyze Git diffs and suggest relevant, conventional commit messages (e.g., feat:, fix:, chore:).
  • Commit all or per file: Optionally commits all changes together or each file separately, each with its own message.
  • Handles new, modified, and deleted files.
  • Works with both staged and unstaged changes.

How It Works

  1. Detects changed files (staged and unstaged).
  2. Gets diffs for each file.
  3. Sends diffs and file info to the LLM via Ollama to generate a commit message.
  4. Commits changes using the generated message(s).
flowchart TD
    A[Start] --> B[Parse Arguments]
    B --> C{Get Changed Files}
    C -->|No changes| Z[No changes detected.]
    C -->|Changes found| D{Commit Per File?}
    D -->|Yes| E[For each file:<br>1. Get diff<br>2. Generate commit message<br>3. Commit file]
    D -->|No| F[For each file:<br>1. Get diff<br>2. Generate commit message]
    F --> G[Combine all messages]
    G --> H[Commit all changes with combined message]
    E --> I[Done]
    H --> I
    Z --> I
    I[End]
Loading

Installation

  • Python 3.7+

  • Olama

  • Ollama Model

This script currently uses the gemma3:4b model.

ollama run gemma3:4b
  • Ollama Python client
pip install ollama
  • Git installed and available in PATH

Usage

If ollama server is running, run the script using the command

python auto_commit.py <repository_path> [single]
  • <repository_path>: Path to your Git repository.
  • single (optional): If provided, commits each file separately; otherwise, all changes are committed together.

Example

Commit all changes in git:

python3 auto_commit.py /Users/ttpho/Documents/GitHub/chat

Commit each file separately:

python3 auto_commit.py /Users/ttpho/Documents/GitHub/chat single

Notes

  • The script uses the gemma3:4b model by default. You can change the model by editing the model variable.
  • Commit messages are limited to 72 characters and follow the Conventional Commits style.
  • The script will print the generated commit messages before committing.

Miscellaneous

Contributions and ideas are welcome, such as:

  • Modifying the prompt, model, or LLM provider.

  • Generating commit messages for individual files or a single message for all files.

  • Optimize or refactor...

About

A Python script that automates the process of generating concise, conventional commit messages for your Git repository changes using an LLM (via Ollama). It can commit all changes at once or commit each file separately, with AI-generated commit messages based on the actual diffs.

Topics

auto-commitgitollamapython3

Resources

Readme
Apache-2.0 license
Activity

Stars

7 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.