You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Commit Message Best Practices](https://ssshooter.com/2020-09-30-commit-message/)
20
+
21
+
## Contributing
22
+
23
+
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests on [GitHub](https://github.com/mingcheng/aigitcommit).
24
+
25
+
## License
26
+
27
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
20
28
21
29
## Features
22
30
23
-
- Generates meaningful, semantic commit messages from staged changes.
24
-
- Commit directly to the repository with the `--commit` flag or copy the generated message with `--copy`.
25
-
- 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.
26
-
- Easy-to-use command-line interface with sensible defaults and confirm prompts (can be skipped with `--yes`).
27
-
- Uses libgit2 via the `git2` crate, avoiding external git commands for improved security and performance.
28
-
- Supports multiple OpenAI-compatible models and configurable API base, token, and proxy settings.
29
-
- Optional auto sign-off of commits when `AIGITCOMMIT_SIGNOFF=true` or `git config --bool aigitcommit.signoff true`.
30
-
- Proxy support: HTTP and SOCKS5 (set via `OPENAI_API_PROXY`).
-**Conventional Commits**: Follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification for consistent, structured messages
33
+
-**Multiple Output Formats**:
34
+
- Human-readable table view (default)
35
+
- JSON format for CI/CD integration and automation
36
+
- Plain text output
37
+
-**Flexible Workflow**:
38
+
- Direct commit with `--commit` flag
39
+
- Copy to clipboard with `--copy-to-clipboard`
40
+
- Git hook integration for automatic message generation
41
+
-**Interactive & Non-Interactive**: Confirmation prompts by default, skip with `--yes` for scripting
42
+
-**Security & Performance**: Uses libgit2 via the `git2` crate, avoiding external git command execution
43
+
-**Multi-Provider Support**: Compatible with OpenAI and other OpenAI-compatible APIs (Azure OpenAI, local models, etc.)
44
+
-**Flexible Configuration**:
45
+
- Environment variables for API settings
46
+
- Git config for repository-specific or global settings
47
+
- Configurable API base URL, token, proxy, and timeouts
48
+
-**Sign-off Support**: Auto sign-off via `AIGITCOMMIT_SIGNOFF` environment variable or `git config aigitcommit.signoff`
49
+
-**Proxy Support**: HTTP and SOCKS5 proxies via `OPENAI_API_PROXY`
31
50
32
51
33
52
## How It Works
34
53
35
-
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.
54
+
AIGitCommit streamlines your commit workflow by:
36
55
37
-
## Install
56
+
1.**Analyzing Changes**: Inspects staged changes using `git diff --cached`
57
+
2.**Understanding Context**: Examines recent commit history for stylistic consistency
58
+
3.**AI Generation**: Sends diffs to an OpenAI-compatible model with carefully crafted prompts
59
+
4.**Structured Output**: Generates commit messages following Conventional Commits specification
60
+
5.**User Review**: Presents the message for review and optional editing
38
61
39
-
AIGitCommit is still in the early stages of development, I suggest you to install it using the git URL using the commands below:
62
+
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.
Both commands will download, compile, and install the binary to your Cargo bin directory (typically `~/.cargo/bin`). Ensure this directory is in your `PATH`.
52
81
53
-
### Docker image
82
+
### Docker Image
54
83
55
-
AIGitCommit can run in Docker if you prefer not to install the binary locally. Example (read-only repository):
84
+
Run AIGitCommit in Docker without installing the binary locally.
85
+
86
+
**Read-only mode** (generate message only):
56
87
57
88
```bash
58
89
docker run \
@@ -65,7 +96,7 @@ docker run \
65
96
ghcr.io/mingcheng/aigitcommit
66
97
```
67
98
68
-
If you want to use `--commit`from inside the container, mount the repo as writable and run interactively:
99
+
**Interactive mode** (with `--commit`flag):
69
100
70
101
```bash
71
102
docker run \
@@ -76,103 +107,209 @@ docker run \
76
107
-e OPENAI_API_TOKEN='<api token>' \
77
108
-e OPENAI_MODEL_NAME='<model name>' \
78
109
-e OPENAI_API_PROXY='<proxy if needed>' \
79
-
ghcr.io/mingcheng/aigitcommit --commit
110
+
ghcr.io/mingcheng/aigitcommit --commit --yes
80
111
```
81
112
82
-
Use `--yes` to skip interactive confirmations.
113
+
Note: Use `--yes` to skip interactive confirmations in non-TTY environments.
83
114
84
-
### Git hook
115
+
### Git Hook
85
116
86
-
AIGitCommit ships a `hooks/prepare-commit-msg` hook that pauses your commit workflow, looks at the staged diff, and pre-populates `COMMIT_EDITMSG` with an AI-generated summary. This lets you fine-tune the final message instead of writing it from scratch.
117
+
AIGitCommit includes a `prepare-commit-msg` hook that automatically generates commit messages during your workflow. The hook triggers when you run `git commit` or `git commit -m ""`, generates a message from staged changes, and opens your editor for review.
87
118
88
119
**Prerequisites**
89
-
-`aigitcommit` must be installed and discoverable on your `PATH`.
90
-
- Required environment variables (`OPENAI_API_TOKEN`, `OPENAI_API_BASE`, etc.) should be configured in your shell before running `git commit`.
91
120
92
-
**Project-level installation**
121
+
-`aigitcommit` must be installed and available in your `PATH`
122
+
- Configure required environment variables before committing (see [Configuration](#configuration))
After copying, stage some changes and run `git commit`. The hook prints progress messages, writes the suggested commit text, and drops you into your editor so you can adjust the result. To verify the hook without creating a new commit, try `git commit --amend` against a throwaway repository.
133
+
After installation, the hook runs automatically when you execute `git commit`. You can review and edit the generated message before finalizing the commit.
102
134
103
-
If you need to disable the hook for a single commit, use`git commit --no-verify`.
135
+
**Disable for a single commit**: Use`git commit --no-verify` to bypass the hook.
104
136
105
-
**Global installation**
137
+
**Global Installation**
106
138
107
-
Install once and reuse across repositories:
139
+
Set up the hook for all new and existing repositories using Git templates:
0 commit comments