Auto Git Commit Message
auto-git-msg 是一个基于 Google Gemini 构建的智能 Git 提交信息生成工具。它不仅仅是一个简单的生成器,更是一个能够理解项目上下文的智能代理(Agent)。
这个工具可以通过分析暂存区(staged)或工作区(unstaged)的代码变更,自动生成符合 Conventional Commits 规范的高质量 Git Commit Message。
✨ 功能特性
- 智能生成: 基于强大的 Gemini 模型分析代码
diff,生成准确、专业的提交信息。 - 遵循规范: 自动格式化为
type(scope): subject的 Conventional Commits 格式。 - 上下文感知: 能够像开发者一样
ls和cd,在生成消息前探索项目结构,提高 scope 的准确性。 - 灵活输入:
- 自动分析暂存区的代码变更。
- 可通过指令分析工作区(未暂存)的变更。
- 可以优化您手写的、不规范的 commit message。
- 智能过滤: 自动忽略
*.lock等版本锁定文件,聚焦核心代码变更。 - 风格参考: 能够获取上一次的 commit message,以保持提交风格的一致性。
- 代理支持: 自动检测并使用系统环境变量(
https_proxy,http_proxy)或配置文件中的代理。
🚀 安装
先决条件
- Python 3.9+
- Git
安装步骤
使用 pip 即可安装:
# 使用 pip
pip install auto-git-msg
⚙️ 配置
首次使用时,工具会提示您输入 Google Gemini API 密钥。输入后,密钥将被自动保存在您用户主目录下的 ~/.auto-git-msg.json 文件中,后续无需再次配置。
您也可以通过命令行参数手动配置:
- 指定密钥(自动保存)
auto-git-msg --api-key YOUR_API_KEY "Generate a commit message"
代理配置
如果您的网络环境需要代理才能访问 Google API,本工具会自动检测 https_proxy 或 http_proxy 环境变量。
您也可以通过命令显式设置或取消代理:
-
设置代理
auto-git-msg --set-proxy http://127.0.0.1:7890
此命令会将代理信息写入
~/.auto-git-msg.json配置文件中。 -
取消代理
auto-git-msg --unset-proxy
📖 使用方法
确保您的代码变更已经通过 git add 添加到暂存区。
基本用法
-
为暂存区的变更生成提交信息
auto-git-msg
-
提供额外指令或上下文 如果变更多而复杂,您可以给 AI 一些提示。
auto-git-msg "这些改动主要重构了后端的认证模块"
-
为未暂存的变更生成提交信息
auto-git-msg "为我所有未暂存的变更生成一个 commit message"
-
优化已有的提交信息 让 AI 帮你把一个简单的想法变成规范的 commit message。
auto-git-msg --message "fix: 修复登录bug"
高级用法
- 在指定项目目录运行
使用
-C或--chdir参数切换到目标目录。auto-git-msg -C ../another-project "为那个项目的改动生成 commit"
📄 许可证
本项目采用 MIT 许可证。
Metadata
Release files for auto-git-msg 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| auto_git_msg-0.1.1.tar.gz | 9.0 kB | Without provenance | Details for auto_git_msg-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| auto_git_msg-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for auto_git_msg-0.1.1-py3-none-any.whl |
Total release size: 18.4 kB
Release files / auto_git_msg-0.1.1.tar.gz
| Download URL | auto_git_msg-0.1.1.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87e063909d86240a9add519c8912ade9f3e1af450c1772076140c50564d88a8b
|
|
BLAKE2b-256 checksum How to use checksums |
97c06de6822a6db7f343e5a9c1de772729b55b3c2d95db60fff085e43d504ae2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.15
|
Release files / auto_git_msg-0.1.1-py3-none-any.whl
| Download URL | auto_git_msg-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a3a358c539699f90c1b27c9c18b5e2567fe0b2e61e9dc5e4f1372f8a2e2f465
|
|
BLAKE2b-256 checksum How to use checksums |
4db897b96ba29d36005bfd142780e2289a234894bd2fd979b839c0a7e06de53f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.15
|
Security for auto-git-msg 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.