用途:按 Conventional Commits 规范创建标准化、语义化的 git 提交。通过分析实际 diff 确定合适的类型、范围与提交信息。
提交格式:<type>[可选 scope]: <description>,可附可选 body 与 footer。
提交类型:feat(新功能)、fix(缺陷修复)、docs(仅文档)、style(格式/样式,无逻辑变更)、refactor(重构,非功能/修复)、perf(性能优化)、test(新增/更新测试)、build(构建系统/依赖)、ci(CI/配置变更)、chore(维护/杂项)、revert(回滚提交)。
破坏性变更:可在类型/范围后加感叹号,如 feat!: remove deprecated endpoint;或使用 BREAKING CHANGE footer,如 feat: allow config to extend other configs 后接 BREAKING CHANGE: extends key behavior changed。
工作流程:1)分析 diff:已暂存用 git diff --staged,未暂存用 git diff,并用 git status --porcelain 查看状态;2)按需暂存:git add path/to/file1 path/to/file2、git add .test.、git add src/components/* 或交互式 git add -p,切勿提交密钥(.env、credentials.json、私钥);3)生成提交信息:确定类型、范围与一行描述(现在时、祈使语气、少于 72 字符);4)执行提交:单行用 git commit -m "<type>[scope]: <description>",多行用 git commit -m "$(cat <<'EOF' ... EOF)" 形式。
最佳实践:每次提交一个逻辑变更;使用现在时(add 而非 added)与祈使语气(fix bug 而非 fixes bug);引用 issue(Closes #123、Refs #456);描述控制在 72 字符内。
Git 安全协议:绝不更新 git config;未经明确要求绝不运行破坏性命令(--force、hard reset);除非用户要求,绝不跳过钩子(--no-verify);绝不强制推送到 main/master;若因钩子导致提交失败,修复后创建新提交(不要 amend)。
限制:资料未提供该技能的具体安装方式、运行环境与平台支持信息。