pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/ttpho/git_diff_auto_commit

origen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/repository-6534fbc3f5e83ac0.css" /> 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. · GitHub
Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

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

This script currently uses the gemma3:4b model.

ollama run gemma3:4b
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

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy