Transform Git Commit Messages with AI: Chain of Draft, Reasoning, and Precision.

1,226 3 days ago

Readme

Git Commit Message Generator

🚀 Installation (macOS/Linux)

Made with VHS

You can install the git-gen-commit script globally with a one-line command:

sudo sh -c 'curl -L https://gist.githubusercontent.com/Tavernari/b88680e71c281cfcdd38f46bdb164fee/raw/git-gen-commit \
     -o /usr/local/bin/git-gen-commit && chmod +x /usr/local/bin/git-gen-commit'

Usage

After installation, simply run:

git gen-commit

This will analyze your git diff and generate a meaningful commit message using AI.

Optional: Add a Shortcut

To use a shorter alias (gcm instead of git gen-commit), add this to your ~/.zshrc or ~/.bashrc:

alias gcm="git gen-commit"

Then, reload your shell:

source ~/.zshrc  # or source ~/.bashrc

Now, you can generate commit messages even faster with:

gcm

Git Commit Message Generator

Step into a new era of commit clarity with the Git Commit Message Generator—an artisanal AI tool designed to transform your code diffs into precise, meaningful commit messages. Whether you’re streamlining your workflow or enriching your project’s history, this model evolves with every update to deliver sharper, more insightful results.

Chain of Draft (Beta)

Introducing a beta feature powered by the Chain of Draft reasoning process! This version iteratively drafts and refines commit messages, providing not just the final output but also a step-by-step draft of its thinking. This transparency makes your commit history more insightful and traceable. Try it out with:

ollama run "tavernari/git-commit-message:cod"

Made with VHS

Reasoning Version (Beta)

Explore another beta feature enhanced with reasoning! This version generates commit messages alongside context and explanations, offering a deeper understanding of your changes. Unlike Chain of Draft, it focuses on clarity through detailed justification rather than iterative drafts. Test it with:

ollama run "tavernari/git-commit-message:reasoning"

Made with VHS

Latest Version

Trained: 26/07/2024

ollama run "tavernari/git-commit-message"

Demo

The core model, independently trained on Mistral 0.3, delivers concise, meaningful commit messages tailored to your diffs. It’s the foundation of this project, continuously improving to meet your coding needs.

Seamless Workflow Integration - macOS Shortcut

Features at a Glance

Version Key Feature Output Includes Command
Chain of Draft Iterative drafting process Final message + draft of thinking ollama run "tavernari/git-commit-message:cod"
Reasoning Version Contextual explanations Final message + context/explanations ollama run "tavernari/git-commit-message:reasoning"
Latest Version Core commit message generation Final message ollama run "tavernari/git-commit-message"

Example

Here’s how it works with a diff (output from the Latest Version):

diff --git forkSrcPrefix/src/cash_calculator.js forkDstPrefix/src/cash_calculator.js
index c9328e4c6ce69fa41d6510a81c266496ed929133..f98fb737032aceaffc56fb60ef7c26da83a3e970 100644
--- forkSrcPrefix/src/cash_calculator.js
+++ forkDstPrefix/src/cash_calculator.js
@@ -10,10 +10,18 @@ function subtract_cash(amount) {
     current_cash = math_operations.subtract(current_cash, amount);
 }
 
+function checkIfTransactionPossible(ammountToRemove) {
+    if (math_operations.subtract(current_cash, ammountToRemove) < 0) {
+        return false;
+    }
+    return true;
+}
+
 function get_cash() {
     return current_cash;
 }
 
 exports.add_cash = add_cash;
 exports.subtract_cash = subtract_cash;
+exports.checkIfTransactionPossible = checkIfTransactionPossible;
 exports.get_cash = get_cash;

Generated Commit Message:

Add check for transaction possibility before subtracting cash

Added a new function `checkIfTransactionPossible` to validate cash subtraction. If the result would drop below zero, it returns false, preventing invalid transactions. This enhances reliability by catching errors early and ensuring only feasible operations proceed.

Note: Beta versions may include extras—Chain of Draft provides the thinking draft, while Reasoning adds context and explanations. Check the output when testing those tags!

How to Use

Getting started is simple:

  1. Prepare your diff (e.g., save it as diff.txt).
  2. Run the model with:
    
    ollama run tavernari/git-commit-message < diff.txt
    
  3. Review the generated commit message and apply it to your project!

Optimizing Your Input

For the best results: - Use clear, well-annotated diffs to help the model distinguish changes. - Break large diffs into smaller chunks for focused, precise messages.

Clear inputs lead to sharper outputs—guide the model to understand your work better!

A Sip of Support for Continuous Learning!

🚀 Every commit message reflects a journey of self-funded machine learning mastery, driven by passion. Your donations fuel this evolution, enhancing model precision and capabilities.

💡 Think of your support as a boost toward smarter AI tools for developers. It powers ongoing training and keeps quality at the forefront.

🤝 Every contribution helps this passion project thrive, free from corporate limits. Join me in pushing AI’s role in development forward!

Support us with a coffee ☕️

Disclaimer

This tool is a labor of love, still evolving as a lightweight assistant. While crafted with care, it’s not perfect—unexpected quirks may arise. Review its suggestions for accuracy before committing to keep it a trusty partner in your workflow.

Connect and Share Feedback!

Your input shapes this tool’s future! Submit diffs and commit messages via this form. Mark great outputs with 👍 or flag issues with 👎—your insights drive progress.

Got ideas, bugs, or just want to chat about AI and coding? Reach me here: - LinkedIn - GitHub - Twitter - Email: victortavernari+gitcommitmessage@gmail.com

Let’s push the boundaries of AI in development together!