用途:完成 worktree 分支的提交、rebase 与合并。源分支提交与直接提交均委托给 git-commit skill。
默认规则:用户指定目标分支则用之,否则解析远程默认分支;解析时优先 origin,无 origin 且仅一个 remote 时用该 remote,通过 git ls-remote --symref <remote> HEAD 读取实时 HEAD(只读,非 fetch/pull)。查询失败时不得静默信任缓存的 refs/remotes/<remote>/HEAD,须停止并要求用户确认。当前 checkout 视为源分支;detached 时先创建源分支(用 git check-ref-format --branch 验证名称,冲突时追加 -2、-3)。除非用户明确要求,不 fetch、pull 或 push;只暂存用户选定文件、已暂存文件、git-commit 空索引时唯一一次 git add . 或冲突解决文件。
预检:解析目标分支;运行 git branch --show-current、git branch --list <target-branch>、git status --short;普通模式运行 git worktree list,查找 branch 为目标的现有 worktree。源与目标相同则进入直接提交模式。多个目标 worktree 时用第一个干净的;全部有变更则记录后先完成源提交再暂停(脏目标暂停),不对脏 worktree 做暂存、提交、stash、restore、clean 等修改,用户清理后回复“继续”。
提交:创建 commit_message.txt 或运行 git commit -F commit_message.txt 前,先发送标题为“提交信息预览”的消息,在 text 代码围栏中显示完整提交信息,除围栏外须与文件内容一致;正文可见后自动继续,除非用户要求确认、仅预览、仅草稿、不提交或修改。
Rebase:先用 git log --oneline <target-branch>..<source-branch> 和 git diff --stat <target-branch>...<source-branch> 检查集成范围;从源 worktree 运行 git rebase <target-branch>,冲突时按语义解决、只暂存已解决文件并 git rebase --continue;之后运行 git diff --check <target-branch>...HEAD。
合并:从现有目标 worktree 合并;无则创建临时 worktree(如 /tmp/worktree-rebase-merge-<repo>-<target>-<pid>)并 git worktree add <temporary-path> <target-branch>,用 git merge <source-branch> 合并,成功后 git worktree remove。不得用 git update-ref、git branch -f 等绕过 worktree,也不为主 checkout 切换分支。按数据要求,缺失事实明确写暂未提供;使用限制如上。