git-auto-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit 自动提交规范
Git Auto-Commit Specification
当用户明确要求“提交 / commit / 推送 / 把改动提交到仓库”时,必须遵循以下规范自动生成 commit message 并执行提交。
When users explicitly request "submit / commit / push / push changes to the repository", the following specifications must be followed to automatically generate a commit message and execute the commit.
决策顺序与优先级
Decision Order and Priority
- 只在用户明确要求时提交:未被要求时,不要主动提交或推送。
- 与 changeset 的前后顺序:若用户同一请求里同时要求“添加 changeset + 提交”,必须先生成 changeset 文件,再执行本 skill(保证 changeset 被包含在提交中)。
- 安全优先:提交前必须检查暂存内容,避免把密钥、token、私钥等敏感信息提交到仓库;如发现疑似敏感信息,先停止并提示用户处理。
- Submit only when explicitly requested by the user: Do not actively commit or push unless requested.
- Order with changeset: If the user requests both "add changeset + commit" in the same request, the changeset file must be generated first, then this skill is executed (to ensure the changeset is included in the commit).
- Security first: Before committing, the staged content must be checked to avoid submitting sensitive information such as keys, tokens, private keys, etc. to the repository; if suspected sensitive information is found, stop first and prompt the user to handle it.
提交流程
Commit Process
- 执行 查看当前变更
git status - 执行 暂存文件(如果用户没有特别说明,默认提交所有变更文件)
git add . - 执行 获取已暂存的关键变更文件列表
git diff --cached --name-only - 通过 git 命令查看关键变更文件的内容后生成符合规范的 commit message(避免凭空猜测)
- 执行 提交
git commit -m "<message>" - 执行 推送到远端(默认行为,除非用户明确说"不 push"或"不推送")
git push
- Execute to view current changes
git status - Execute to stage files (by default, commit all changed files unless the user specifies otherwise)
git add . - Execute to get the list of key changed files that have been staged
git diff --cached --name-only - Generate a standardized commit message after viewing the content of key changed files via git commands (avoid guessing out of thin air)
- Execute to commit
git commit -m "<message>" - Execute to push to the remote repository (default behavior, unless the user explicitly says "don't push" or "no push")
git push
推送规则
Push Rules
- 默认推送:提交完成后自动执行
git push - 跳过推送:仅当用户明确表示"不 push"、"不推送"、"只 commit"等类似意图时,才跳过推送步骤
- 推送失败处理:如果推送失败,提示用户可能的原因(如需要先 pull、无远端分支等)
- Default push: Automatically execute after commit is completed
git push - Skip push: Skip the push step only when the user explicitly expresses intentions such as "don't push", "no push", "only commit", etc.
- Push failure handling: If push fails, prompt the user for possible reasons (such as needing to pull first, no remote branch, etc.)
Commit Message 规范
Commit Message Specification
规范来源优先级
Priority of Specification Sources
-
优先读取项目根目录下的配置文件
.commitlintrc.xx- 如果存在该配置文件,严格遵循其中定义的规范
- 读取可用的 commit type 列表及对应的 emoji
- 读取 scope 的允许值及其他提交规则
-
如果没有配置文件
.commitlintrc.xx- 参考 commit-message-convention.md 中的默认规范
- 使用标准的 conventional commits 格式
-
Prioritize reading theconfiguration file in the project root directory
.commitlintrc.xx- If the configuration file exists, strictly follow the specifications defined in it
- Read the list of available commit types and corresponding emojis
- Read the allowed values of scope and other commit rules
-
If there is noconfiguration file
.commitlintrc.xx- Refer to the default specification in commit-message-convention.md
- Use the standard conventional commits format
输出要求(必须满足)
Output Requirements (Must Be Met)
- 提交信息可追溯:message 必须与暂存的变更内容匹配,不允许与实际改动不一致
- 最小惊扰:默认提交全部变更;若用户只想提交部分文件,必须按用户指定范围暂存
- 遵循仓库规范:存在 commitlint 配置时必须严格遵循,否则按默认规范生成
- Traceable commit information: The message must match the staged change content; inconsistency with actual changes is not allowed
- Minimal disturbance: Commit all changes by default; if the user only wants to submit some files, stage them according to the user-specified scope
- Follow repository specifications: Strictly follow the commitlint configuration if it exists; otherwise, generate according to the default specification
使用场景
Usage Scenarios
- 用户要求提交代码
- 任务完成后需要保存变更
- 需要生成规范的 commit message
- User requests to submit code
- Need to save changes after task completion
- Need to generate a standardized commit message