AIGitCommit

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.
References
- https://www.conventionalcommits.org/en/v1.0.0/
- https://nitayneeman.com/blog/understanding-semantic-commit-messages-using-git-and-angular/
- https://ssshooter.com/2020-09-30-commit-message/
Features
- Generates meaningful, semantic commit messages from staged changes.
- Commit directly to the repository with the
--commitflag or copy the generated message with--copy. - Output formats: human-readable text, JSON (machine-readable) and table view. JSON output is useful for CI integrations and automation; table view makes it easy to scan multiple suggested lines.
- Easy-to-use command-line interface with sensible defaults and confirm prompts (can be skipped with
--yes). - Uses libgit2 via the
git2crate, avoiding external git commands for improved security and performance. - Supports multiple OpenAI-compatible models and configurable API base, token, and proxy settings.
- Optional auto sign-off of commits when
GIT_AUTO_SIGNOFF=true. - Proxy support: HTTP and SOCKS5 (set via
OPENAI_API_PROXY).
How It Works
AIGitCommit inspects your staged Git changes, summarizes the intent of those changes, and generates clear semantic commit messages. It examines diffs and uses an AI model to infer intent and produce concise, useful commit lines.
Install
AIGitCommit is still in the early stages of development, I suggest you to install it using the git URL using the commands below:
cargo install --git https://github.com/mingcheng/aigitcommit.git
or, You can install from crates.io
cargo install aigitcommit
Those command will auto-download the latest version of the project and install it to your cargo bin directory.
Docker image
AIGitCommit can run in Docker if you prefer not to install the binary locally. Example (read-only repository):
If you want to use --commit from inside the container, mount the repo as writable and run interactively:
Use --yes to skip interactive confirmations.
Git hook
AIGitCommit ships a hooks/prepare-commit-msg hook you can copy into a repository's .git/hooks/prepare-commit-msg to automatically generate commit messages during git commit.
To install globally:
# copy the file from this project into ~/.git-hooks/prepare-commit-msg
After installing the hook, git commit will run the hook and populate the commit message. Use --no-verify to bypass hooks when necessary.
Configuration
Before using AIGitCommit, export the following environment variables (for example in your shell profile):
OPENAI_API_TOKEN: Your OpenAI-compatible API token.OPENAI_API_BASE: The API base URL (useful for alternative providers or local proxies).OPENAI_MODEL_NAME: The model name to query (e.g., a GPT-compatible model).OPENAI_API_PROXY: Optional. Proxy address for network access (e.g.,http://127.0.0.1:1080orsocks://127.0.0.1:1086).GIT_AUTO_SIGNOFF: Optional. Set totrueto append a Signed-off-by line to commits.
Check the configuration
After setting the environment variables, you can check if they are set correctly by running:
This will print the current configuration and verify that the required variables are set.
Then you can run
to check if the specified model is available and can be queried successfully.
You can also run aigitcommit --help to see the available options and usage instructions.
Usage
Run aigitcommit in a repository with staged changes. Optionally provide a path to the git directory: aigitcommit <dir>.
Common flags:
--commitcommit generated message directly to the repository.--copy-to-clipboardcopy the generated message to the clipboard.--jsonprint the suggestions as JSON for CI or automation.--yesskip confirmation prompts and apply the default action.--signoffappend a Signed-off-by line to the commit message.
See aigitcommit --help for the full list of options.
License
This project is licensed under the MIT License. See the LICENSE file for details.