用途:当你在 main(或类似 petname 的占位分支)上开发后准备提 PR 时,该技能会创建命名规范的功能分支,并把已有提交和未提交改动一并迁移过去,保留提交历史与工作区状态。
主要能力:先并行执行 git branch --show-current、git log origin/main..HEAD --oneline、git diff --stat、git diff --cached --stat 判断当前分支类型;识别 main/master、占位分支(如 useful-pony 这类两词小写连字符名,或 wip、tmp、test 等)、已规范分支(^(feat|fix|refactor|docs|test|chore|perf|ci)/.+)以及受保护分支(develop、dev、staging、production、release/*)。对 main 走迁出流程,对占位分支走原地重命名流程,对已规范分支或受保护分支则中止。
分支命名:格式为 <type>/<short-kebab-description>,type 取 feat、fix、refactor、docs、test、chore、perf、ci,长度控制在 50 字符内。
使用方式:迁出分三种情况——有提交且有未提交改动时用 git stash --include-untracked、git branch、git reset --hard origin/main、git switch、git stash pop;仅有提交时省略 stash 步骤;仅有未提交改动时用 git switch -c。占位分支则用 git branch -m 原地重命名,若已推送还需 git push origin :<old> <new> 与 git push -u origin <new>。最后用 git branch --show-current、git log、git status --short 验证并输出摘要,建议接着运行 /make-pr。
限制:比较前需先 git fetch origin main;origin/main 不存在时可改用 origin/master 或中止;不提交未提交改动,只原样迁移;不强制删除或丢失提交;受保护分支不处理。具体安装与调用细节资料未提供。