git-worktree-feature-flow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Worktree Feature Flow
Git Worktree 功能分支流程
Use this skill when the user wants an isolated working directory for a feature (via ), then to merge that branch back into a target branch and clean up the worktree.
git worktree当用户需要为某个功能创建独立的工作目录(通过),随后将该分支合并回目标分支并清理worktree时,可使用此技能。
git worktreeExamples (user prompts)
示例(用户提示)
- "Create a worktree for off
feature/foo."main - "Spin up a worktree for my change, put it in ."
../wts/feature-foo - "Merge my worktree branch back into with a squash merge, then clean up."
main - "Finish the worktree for but keep the branch around."
feature/foo
- "基于分支为
main创建worktree。"feature/foo - "为我的修改创建一个worktree,将其放在目录下。"
../wts/feature-foo - "通过 squash 合并将我的worktree分支合并回,然后进行清理。"
main - "完成的worktree工作,但保留该分支。"
feature/foo
Quick flow
快速流程
- Start: create a feature worktree
- Ask for name (required).
branch - Optional: ask for ref (default: current branch).
base - Run .
scripts/worktree-start.sh
-
Work: user edits/commits in the worktree directory.
-
Finish: merge + cleanup
- Ask for merge :
strategy(default),merge, orsquash.ff-only - Optional: ask for target branch (default: detected repo default branch, usually
into).main - Run .
scripts/worktree-finish.sh
- 开始:创建功能分支worktree
- 询问分支名称(必填项)。
branch - 可选:询问基准引用(默认值:当前分支)。
base - 运行脚本。
scripts/worktree-start.sh
-
工作:用户在worktree目录中进行编辑/提交。
-
完成:合并+清理
- 询问合并策略:
strategy(默认值)、merge或squash。ff-only - 可选:询问目标分支(默认值:自动检测的仓库默认分支,通常为
into)。main - 运行脚本。
scripts/worktree-finish.sh
Commands (scripts)
命令(脚本)
Start a worktree
启动worktree
bash
$HOME/.codex/skills/git-worktree-feature-flow/scripts/worktree-start.sh --branch feature/my-changeCommon options:
- : base branch/ref to branch from (default: current branch)
--base <ref> - : where to place the worktree (default: sibling
--path <dir>).worktrees/<repo>/<branch>- If is relative, it’s interpreted relative to the repo root.
--path
- If
- : do not prompt
--yes
bash
$HOME/.codex/skills/git-worktree-feature-flow/scripts/worktree-start.sh --branch feature/my-change常用选项:
- :用于创建分支的基准分支/引用(默认值:当前分支)
--base <ref> - :worktree的存放路径(默认值:同级目录
--path <dir>).worktrees/<repo>/<branch>- 如果为相对路径,则相对于仓库根目录解析。
--path
- 如果
- :不进行提示,直接执行
--yes
Finish (merge back and clean up)
完成(合并回主分支并清理)
bash
$HOME/.codex/skills/git-worktree-feature-flow/scripts/worktree-finish.sh --branch feature/my-changeCommon options:
- : target branch to merge into (default: detected default branch)
--into <branch> - : merge strategy (default:
--strategy merge|squash|ff-only)merge - : keep the feature branch after merging
--no-delete-branch - : keep the worktree directory after merging
--keep-worktree - : do not prompt
--yes
Notes:
- implies you should also pass
--keep-worktree(you can’t delete a branch that’s still checked out in a worktree).--no-delete-branch - For , the script creates a squash commit automatically and may force-delete the feature branch after committing (use
--strategy squashto keep it).--no-delete-branch
bash
$HOME/.codex/skills/git-worktree-feature-flow/scripts/worktree-finish.sh --branch feature/my-change常用选项:
- :要合并到的目标分支(默认值:自动检测的默认分支)
--into <branch> - :合并策略(默认值:
--strategy merge|squash|ff-only)merge - :合并后保留功能分支
--no-delete-branch - :合并后保留worktree目录
--keep-worktree - :不进行提示,直接执行
--yes
注意事项:
- 使用时,也应同时传递
--keep-worktree参数(无法删除仍在worktree中被检出的分支)。--no-delete-branch - 对于策略,脚本会自动创建一个squash提交,合并后可能会强制删除功能分支(使用
--strategy squash可保留该分支)。--no-delete-branch
Agent guidelines
Agent 操作指南
- Prefer the scripts in over manually typing long
scripts/commands.git worktree - Confirm the user’s intended ,
branch, and mergebasebefore making changes.strategy - Be conservative:
- Refuse to proceed if the feature worktree has uncommitted changes unless the user explicitly wants to continue.
- Refuse to proceed if the target worktree (where the merge happens) is dirty.
- If cleaning up, don’t run the finish step from inside the feature worktree directory.
- After finishing, summarize:
- where the worktree lived,
- what merge strategy was used,
- whether the branch/worktree were deleted.
- 优先使用目录下的脚本,而非手动输入冗长的
scripts/命令。git worktree - 在进行更改前,确认用户指定的分支、
branch基准分支和合并base策略。strategy - 操作需谨慎:
- 如果功能分支worktree存在未提交的更改,除非用户明确要求继续,否则拒绝执行后续步骤。
- 如果目标worktree(执行合并操作的目录)存在未提交更改,拒绝执行后续步骤。
- 清理时,不要在功能分支worktree目录内执行完成步骤。
- 完成操作后,总结以下信息:
- worktree的存放路径,
- 使用的合并策略,
- 是否已删除分支/worktree。