| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
AIGitCommit is a command-line tool that generates meaningful, semantic commit messages from your staged Git changes using AI.
It inspects your diffs, summarizes the intent of your changes, and produces clear, concise commit messages that follow the Conventional Commits specification.
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.
AIGitCommit streamlines your commit workflow by:
The tool uses libgit2 for secure, efficient Git operations without spawning external processes. It automatically filters out common noise files (lock files, generated code) to focus on meaningful changes.
cargo install aigitcommitFor the latest development version:
cargo install --git https://github.com/mingcheng/aigitcommit.gitBoth commands will download, compile, and install the binary to your Cargo bin directory (typically ~/.cargo/bin). Ensure this directory is in your PATH.
Run AIGitCommit in Docker without installing the binary locally.
Read-only mode (generate message only):
docker run \
--rm \
-v $PWD:/repo:ro \
-e OPENAI_API_BASE='<api base>' \
-e OPENAI_API_TOKEN='<api token>' \
-e OPENAI_MODEL_NAME='<model name>' \
-e OPENAI_API_PROXY='<proxy if needed>' \
ghcr.io/mingcheng/aigitcommitInteractive mode (with --commit flag):
docker run \
--rm \
-it \
-v $PWD:/repo:rw \
-e OPENAI_API_BASE='<api base>' \
-e OPENAI_API_TOKEN='<api token>' \
-e OPENAI_MODEL_NAME='<model name>' \
-e OPENAI_API_PROXY='<proxy if needed>' \
ghcr.io/mingcheng/aigitcommit --commit --yesNote: Use --yes to skip interactive confirmations in non-TTY environments.
AIGitCommit includes a prepare-commit-msg hook that automatically generates commit messages during your workflow.
Quick install (recommended)
Install into the current repository:
aigitcommit install-hook .Install into a specific repository:
aigitcommit install-hook /path/to/repoIf a prepare-commit-msg hook already exists, it is renamed to prepare-commit-msg.bak before the new hook is written, so your previous hook is preserved (any prior .bak is overwritten).
Prerequisite: aigitcommit is installed and available in your PATH.
Prerequisites
Manual install (alternative)
cp hooks/prepare-commit-msg .git/hooks/prepare-commit-msg
chmod +x .git/hooks/prepare-commit-msgDisable for a single commit: Use git commit --no-verify to bypass the hook.
Global installation (optional)
Use Git templates so new repos have the hook:
mkdir -p ~/.git-template/hooks
cp hooks/prepare-commit-msg ~/.git-template/hooks/prepare-commit-msg
chmod +x ~/.git-template/hooks/prepare-commit-msg
git config --global init.templateDir ~/.git-templateApply to an existing repo (either copy the file or re-init):
cp ~/.git-template/hooks/prepare-commit-msg <repo>/.git/hooks/
# or
cd <repo> && git initHook behavior (summary)
Troubleshooting
Configure AIGitCommit by setting these environment variables (in your shell profile, .bashrc, .zshrc, etc.):
Required:
Optional:
Example configuration:
# ~/.bashrc or ~/.zshrc
export OPENAI_API_TOKEN="sk-..."
export OPENAI_API_BASE="https://api.openai.com/v1"
export OPENAI_MODEL_NAME="gpt-4"
export OPENAI_API_PROXY="http://127.0.0.1:1080" # Optional
export AIGITCOMMIT_SIGNOFF="true" # OptionalYou can also enable sign-off via Git configuration (takes precedence over environment variables):
# Repository-specific
git config aigitcommit.signoff true
# Global (all repositories)
git config --global aigitcommit.signoff trueCheck your environment setup:
# Verify all environment variables
aigitcommit --check-env
# Test API connectivity and model availability
aigitcommit --check-model
# Show all available options
aigitcommit --helpRun AIGitCommit in a Git repository with staged changes:
# In the current repository
aigitcommit
# Specify a different repository path
aigitcommit /path/to/repoThe tool will:
Output Formats:
Actions:
Cache:
Diagnostics:
Generate and review message:
aigitcommitAuto-commit without confirmation:
aigitcommit --commit --yesCopy message to clipboard:
aigitcommit --copy-to-clipboardJSON output for CI pipelines:
aigitcommit --json | jq '.title'Commit with sign-off:
aigitcommit --commit --signoffResponses are cached under <repo>/.git/aigitcommit-cache/ and keyed by the staged diff, recent commit logs, model and prompt. Any change to those inputs invalidates the entry automatically. Use --no-cache to bypass it for a single run, or --clear-cache to wipe it.
Typical workflow:
# Stage your changes
git add .
# Generate and review commit message
aigitcommit
# Or commit directly
aigitcommit --commit
# Or use the Git hook (if installed)
git commit # Hook generates message automaticallyThis project is licensed under the MIT License. See the LICENSE file for details.
| Back | FazBrowse Home | New Git URL |