worktree-merge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWorktree Merge
Worktree Merge
Integrate any number of feature branches into your working branch through a single throwaway integration
branch, so nothing lands on the main line until every branch is merged and the whole suite passes. Validation
commands are detected from the repo, never assumed.
通过一个一次性的集成分支,将任意数量的特性分支整合到你的工作分支中,确保所有分支合并完成且整个检查套件通过后,才会有内容合并到主线分支。验证命令会从仓库中自动检测,而非预设。
Input
输入
$ARGUMENTS- Fewer than two → ask which branches to integrate. Don't guess.
- Two or more → integrate them in the given order.
$ARGUMENTS- 少于2个分支 → 询问用户需要整合哪些分支,不要自行猜测。
- 2个及以上分支 → 按照给定顺序进行整合。
Detect the validation commands ONCE
仅检测一次验证命令
Find the commands that prove this project works, preferring what CI already runs: read , a
, or the manifest's test/lint scripts, and reuse those exact commands (test runner, type checker,
linter). Do not hardcode // — use whatever this repo actually uses.
.github/workflows/*Makefilepytestmypypyright找出能验证项目正常运行的命令,优先选择CI已在运行的命令:读取 、 或清单中的测试/ lint脚本,并直接复用这些命令(测试运行器、类型检查器、代码检查工具)。不要硬编码 // —— 使用仓库实际使用的工具。
.github/workflows/*MakefilepytestmypypyrightSteps
步骤
-
Preconditions. Confirm you're at the repository root, not inside(
worktrees/→ error). Store the current branch. Verify every branch in the list exists ([[ $(pwd) =~ /worktrees/ ]]). Abort early with a clear message if any check fails.git rev-parse --verify <branch> -
Create one integration branch off the current branch, named for the set (e.g., with a short suffix if there are several — keep it filesystem-safe). This is where merges are tested; the main line stays untouched until the end.
integration-<first> -
Merge each branch in order,. After each merge, run the detected test command so a break is localized to the branch that caused it.
--no-ff- On conflict: stop, name the conflicting branch and files, and give resolution steps (resolve →
→
git add→ re-run the skill). Don't attempt automatic resolution.git commit - On test failure: stop, report which tests failed, and give the rollback (→
git checkout <original>).git branch -D <integration>
- On conflict: stop, name the conflicting branch and files, and give resolution steps (resolve →
-
Full validation once all branches are merged: run the project's complete detected suite (tests + type checks + lint). Any failure → report it and roll back; nothing reaches the main line red.
-
Merge the integration branch into the original branch (), then delete the integration branch.
--no-ff -
Offer cleanup with AskUserQuestion: remove the N worktrees and delete their feature branches, or keep them. On yes, for each branch:and
git worktree remove worktrees/<branch>.git branch -d <branch>
-
前置条件。确认当前处于仓库根目录,而非目录内(
worktrees/→ 报错)。保存当前分支。验证列表中的每个分支都存在([[ $(pwd) =~ /worktrees/ ]])。如果任何检查失败,提前终止并给出清晰提示。git rev-parse --verify <branch> -
基于当前分支创建一个集成分支,命名与分支集合相关(例如,如果有多个分支则添加短后缀——确保名称符合文件系统规范)。所有合并测试都将在此分支进行;主线分支在最后之前不会被改动。
integration-<first> -
按顺序合并每个分支,使用参数。每次合并后,运行检测到的测试命令,以便定位导致问题的分支。
--no-ff- 出现冲突时:停止操作,指出冲突的分支和文件,并给出解决步骤(解决冲突 → →
git add→ 重新运行该技能)。不要尝试自动解决冲突。git commit - 测试失败时:停止操作,报告失败的测试内容,并给出回滚命令(→
git checkout <original>)。git branch -D <integration>
- 出现冲突时:停止操作,指出冲突的分支和文件,并给出解决步骤(解决冲突 →
-
所有分支合并完成后进行完整验证:运行项目检测到的完整检查套件(测试 + 类型检查 + 代码检查)。任何失败 → 报告问题并回滚;确保主线分支不会出现未通过检查的内容。
-
将集成分支合并到原始分支(使用参数),然后删除集成分支。
--no-ff -
提供清理选项:询问用户是否移除N个工作树并删除对应的特性分支,或保留它们。如果用户同意,对每个分支执行:和
git worktree remove worktrees/<branch>。git branch -d <branch>
Report
报告
- Success: the integration branch used, each branch merged (with its post-merge test result), the full
validation result, the merge into , and cleanup status (worktrees kept or removed, with the manual cleanup commands if kept).
<original> - Failure: the step and branch that failed, the current branch state, and exact rollback commands
(→
git checkout <original>), plus how to continue after fixing (re-run with the same branch list).git branch -D <integration>
- 成功时:说明使用的集成分支、每个已合并的分支(及其合并后的测试结果)、完整验证结果、合并到分支的情况,以及清理状态(工作树已保留或移除,若保留则给出手动清理命令)。
<original> - 失败时:说明失败的步骤和分支、当前分支状态,以及精确的回滚命令(→
git checkout <original>),并告知修复后如何继续(使用相同的分支列表重新运行该技能)。git branch -D <integration>
Notes
注意事项
- preserves each feature branch's history.
--no-ff - The integration branch is disposable — the original branch only moves after every merge and the full suite pass.
- Prefer opening a PR per branch when you're on a team; this skill is for fast local integration when you own the merge.
- 参数会保留每个特性分支的提交历史。
--no-ff - 集成分支是一次性的——只有在所有合并完成且完整检查套件通过后,原始分支才会更新。
- 在团队协作中,建议为每个分支创建PR;该技能适用于你拥有合并权限时的快速本地集成场景。