gitkit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegitkit
gitkit
One place where the git facts live that every other skill in a toolchain keeps re-deriving: where a worktree goes and what it's named, how it is created, adopted, and removed, which branch is the base, and when to rebase versus merge.
Nothing here is clever. All of it is native git worktree — no vendor CLI, no GUI dependency, no recorded state anywhere but git's own. That is the point: a laptop with a desktop dev tool and a headless Linux box run identical commands, so there is no second code path to keep in sync and no "degraded mode" to reason about.
gitkit is a primitives skill. Most of its runs come from another skill calling it, not from a human saying its name.
这是一个存储Git相关信息的统一位置,工具链中的其他所有技能都反复从中获取信息:worktree的存放路径与命名规则、创建、采用和删除方式、基准分支是什么,以及何时选择变基而非合并。
这里没有任何花哨的内容。所有操作均基于原生的git worktree——无需厂商CLI、无需GUI依赖、除Git自身外无任何记录状态。这正是核心所在:无论是装有桌面开发工具的笔记本电脑,还是无界面Linux服务器,都运行完全相同的命令,因此无需维护第二条代码路径,也无需考虑“降级模式”。
gitkit是一项基础技能。它的大多数运行场景来自其他技能的调用,而非用户直接触发。
When this fires
触发场景
- worktree — "spin up a worktree for this branch", "make me a worktree for #42", "where is the worktree for ", "tear down this worktree", "list my worktrees", "clean up the ones that are merged".
issue-42-… - base ref — "what's the base branch here", "diff me against the base".
- sync — "should I rebase or merge here", "this branch is behind — bring it up to date".
- called by another skill — any skill that needs a worktree, a base ref, a branch name, or a sync decision delegates here and uses what comes back.
Not this skill: committing, opening a PR, reviewing a diff, judging code. gitkit answers where and how, never what the change should be.
- worktree相关 —— “为这个分支创建一个worktree”“帮我为#42创建一个worktree”“的worktree在哪里”“删除这个worktree”“列出我的worktree”“清理已合并的worktree”。
issue-42-… - 基准引用相关 —— “这里的基准分支是什么”“对比我与基准分支的差异”。
- 同步相关 —— “我在这里应该变基还是合并”“这个分支落后了——更新它”。
- 被其他技能调用 —— 任何需要worktree、基准引用、分支名称或同步决策的技能都会委托本技能处理,并使用返回结果。
不属于本技能的范畴:提交代码、打开PR、审查差异、评估代码。gitkit只回答在哪里以及如何操作,从不回答应该做出什么变更。
The convention
约定规则
Path
路径
$WORKTREE_ROOT/<repo-basename>/<local-branch-name>$WORKTREE_ROOT~/worktrees<repo-basename>Slashes in a branch name flatten to dashes. A branch gets the directory , not a nested parent. This keeps one flat level per repo, so is a complete inventory rather than a tree to walk. The trade is that the directory name no longer round-trips back to the branch name — which costs nothing, because lookup is always through git, never by reading a path. On the rare collision (branches and both flatten to ), fails on the existing path: report it and let the human pick a name rather than silently appending a suffix.
mimukit/6-marketing-sitemimukit-6-marketing-sitemimukit/ls "$WORKTREE_ROOT/<repo>"a/ba-ba-bgit worktree addWorktrees live outside the repository, never in a directory inside it. An in-repo worktree gets swept into docker build contexts, bind mounts, file watchers, and test globs — and every one of those failures shows up far from its cause.
.worktrees/$WORKTREE_ROOT/<repo-basename>/<local-branch-name>$WORKTREE_ROOT~/worktrees<repo-basename>分支名称中的斜杠会替换为短横线。例如分支对应的目录为,而非嵌套的父目录。这样每个仓库的worktree都处于同一层级,因此即可查看完整清单,无需遍历目录树。代价是目录名称无法反向映射回分支名称——但这并无影响,因为查找始终通过Git完成,而非读取路径。在极少数冲突情况下(分支和均会转换为),会因路径已存在而失败:此时需向用户报告该情况,让用户选择一个名称,而非静默添加后缀。
mimukit/6-marketing-sitemimukit-6-marketing-sitemimukit/ls "$WORKTREE_ROOT/<repo>"a/ba-ba-bgit worktree addWorktree存放在仓库外部,绝不能放在仓库内的目录中。仓库内的worktree会被纳入Docker构建上下文、绑定挂载、文件监视器和测试通配符——而这些问题的出现往往与原因相距甚远。
.worktrees/The invariant: one branch, one worktree
不变原则:一个分支对应一个worktree
A branch has at most one worktree, and the directory is named after it. A worktree is keyed to a branch, not to a workflow stage — so implementing a feature and later reviewing its pull request use the same worktree, because they are the same branch.
This is not a style preference. Git enforces it:
$ git worktree add ../wt-b feature-x
fatal: 'feature-x' is already used by worktree at '.../wt-a'Any scheme that names worktrees by stage (, ) hard-fails the moment two stages touch one branch — which is the normal case, not the edge case.
review-…qa-…Consequences:
- Lookup is by branch, always — through git, never by reading or guessing at a directory path. This is what makes the flattening above free, and what lets a worktree sitting in some older root keep working untouched.
- The "kind" of a worktree rides along for free, because the branch name already carries it. is named that because the branch was named that when the work started.
issue-42-auth-capability-module
一个分支最多对应一个worktree,且目录以分支命名。worktree与分支绑定,而非与工作流阶段绑定——因此实现功能和后续审查其PR使用同一个worktree,因为它们属于同一个分支。
这并非风格偏好,而是Git强制要求的:
$ git worktree add ../wt-b feature-x
fatal: 'feature-x' is already used by worktree at '.../wt-a'任何按阶段命名worktree的方案(如、)都会在同一分支涉及两个阶段时直接失败——这是正常情况,而非边缘案例。
review-…qa-…由此产生的结果:
- 始终通过分支查找 —— 通过Git完成,而非读取或猜测目录路径。这使得上述的斜杠替换操作无任何代价,也让位于旧根目录下的worktree无需修改即可继续使用。
- worktree的“类型”自动附带 —— 因为分支名称本身已包含该信息。之所以命名如此,是因为开始工作时分支就是这样命名的。
issue-42-auth-capability-module
Branch naming
分支命名
- — work that starts from a tracker issue. Slug from the issue title: if it follows a conventional
issue-<n>-<slug>form, strip the prefix; kebab-case the rest, cap at roughly 50 characters on a word boundary, drop a trailing hyphen. An empty slug degrades to a baretype(scope): summary. The number guarantees uniqueness, so no tie-break is ever needed.issue-<n> - — only for a fork pull request, where no local branch exists yet and one must be invented to hold the fetched head. Slug from the head branch name, kebab-cased, capped at roughly 40 characters.
pr-<n>-<slug> - Anything else — a branch name the human or the repo's convention supplies. gitkit does not rename it.
For a same-repo pull request there is already a local branch name: use it. Inventing a name for a branch that exists is how you land on the two-worktrees-one-branch failure above.
pr-*- —— 源于跟踪器任务的工作。Slug来自任务标题:如果标题遵循常规的
issue-<n>-<slug>格式,则去掉前缀;其余部分转换为短横线命名法,在单词边界处截断至约50字符,删除末尾的短横线。若slug为空,则简化为type(scope): summary。编号保证了唯一性,因此无需任何冲突解决机制。issue-<n> - —— 仅适用于分叉仓库的PR,此时本地不存在对应分支,必须创建一个分支来存放拉取的头部内容。Slug来自头部分支名称,转换为短横线命名法,截断至约40字符。
pr-<n>-<slug> - 其他情况 —— 用户或仓库约定提供的分支名称。gitkit不会重命名该分支。
对于同仓库的PR,本地已有对应的分支名称:直接使用即可。为已存在的分支创建名称会导致上述“一个分支两个worktree”的失败情况。
pr-*Worktree operations
Worktree操作
All four are native git, and all four are idempotent — running one twice is a normal thing to do and must never error or destroy work.
所有四种操作均为原生Git命令,且均具备幂等性——重复执行不会报错或破坏工作内容。
Look up a branch's worktree
查找分支对应的worktree
The one lookup primitive everything else is built on:
sh
git -C "$REPO" worktree list --porcelainEach record carries a line and, when a branch is checked out, a line. Match on the branch to get the path. If the porcelain shape ever shifts, check rather than guessing — but treat the / pairing as stable; that is what porcelain output is for.
worktree <path>branch refs/heads/<name>git worktree list --helpworktreebranch这是构建所有其他功能的基础查找原语:
sh
git -C "$REPO" worktree list --porcelain每条记录包含行,当分支被检出时,还包含行。通过分支匹配即可获取路径。若输出格式发生变化,请查看而非猜测——但需将/的配对视为稳定格式;这正是porcelain输出的用途。
worktree <path>branch refs/heads/<name>git worktree list --helpworktreebranchCreate — or adopt
创建——或采用
Always look first. If a worktree already exists for the branch, adopt it: report the path and stop. Never create a second one, never error.
When there is none:
sh
git -C "$REPO" fetch origin --prune
git -C "$REPO" worktree add -b "$BRANCH" "$WORKTREE_ROOT/$(basename "$REPO")/$BRANCH" "$BASE"- Fetch first, always. Branching off a stale base is silent and only surfaces as conflicts later.
- comes from The base ref — never a hard-coded
$BASE, and never a sibling feature branch.origin/main - Drop when the branch already exists locally (a same-repo PR you have fetched, a branch you made earlier);
-bchecks it out.git worktree add <path> <branch> - For a fork pull request, fetch the head into a local branch first — — then add the worktree on that branch, no
git fetch origin "pull/<n>/head:pr-<n>-<slug>".-b
Report the path and the branch. Creating a worktree does not imply doing anything in it.
始终先进行查找。如果分支对应的worktree已存在,则采用它:报告路径并停止操作。绝不能创建第二个worktree,也不能报错。
若不存在对应worktree:
sh
git -C "$REPO" fetch origin --prune
git -C "$REPO" worktree add -b "$BRANCH" "$WORKTREE_ROOT/$(basename "$REPO")/$BRANCH" "$BASE"- 始终先执行Fetch操作。基于过时的基准分支创建分支是静默操作,只会在后续引发冲突。
- 来自基准引用——绝不能硬编码为
$BASE,也不能是同级功能分支。origin/main - 当分支已在本地存在时(如已拉取的同仓库PR、之前创建的分支),去掉参数;
-b会检出该分支。git worktree add <path> <branch> - 对于分叉仓库的PR,先将头部内容拉取到本地分支————然后基于该分支添加worktree,无需
git fetch origin "pull/<n>/head:pr-<n>-<slug>"参数。-b
报告路径和分支名称。创建worktree并不意味着在其中执行任何操作。
Remove
删除
sh
git -C "$REPO" worktree remove "$WT"
git -C "$REPO" branch -d "$BRANCH" # only a branch you created, and only if mergedThree rules, each one guarding against a real way to lose work:
- A dirty worktree stops teardown. Show exactly what would be lost — uncommitted changes, untracked files, unpushed commits — and let the human decide. Never reach for on their behalf.
--force - Never remove a worktree you adopted rather than created. If it was already there when you arrived, it is someone else's context; you have no idea what is open in it.
- Never delete a branch you did not create. (not
-d) so git itself refuses an unmerged branch.-D
Already gone? Report "already gone" and succeed. Teardown is idempotent in the same spirit as adopt.
sh
git -C "$REPO" worktree remove "$WT"
git -C "$REPO" branch -d "$BRANCH" # 仅适用于你创建的分支,且仅当该分支已合并时三条规则,每条都能防止实际工作中丢失内容:
- 脏worktree会阻止删除操作。明确显示会丢失的内容——未提交的变更、未跟踪的文件、未推送的提交——让用户决定。绝不能代表用户使用参数。
--force - 绝不能删除你采用而非创建的worktree。如果它在你接手时已存在,则属于他人的工作环境;你不知道其中打开了什么内容。
- 绝不能删除你未创建的分支。使用(而非
-d),这样Git会拒绝删除未合并的分支。-D
如果worktree已不存在?报告“已不存在”并返回成功。删除操作与采用操作一样具备幂等性。
List
列出
sh
git -C "$REPO" worktree listWorth pairing with a staleness signal when the user asks to clean up — a worktree whose branch is fully merged into the base is a teardown candidate. Offer them; do not remove on your own initiative.
If paths look wrong after a move or a restore, rewrites the back-pointers. Git stores absolute paths in and in each worktree's file, so moving a worktree by hand always needs a repair.
git worktree repair <path>.git/worktrees/<name>/gitdir.gitsh
git -C "$REPO" worktree list当用户要求清理时,最好附带过时标识——分支已完全合并到基准分支的worktree是删除候选。可向用户推荐删除,但绝不能自行删除。
若移动或恢复后路径显示异常,会重写反向指针。Git在和每个worktree的文件中存储绝对路径,因此手动移动worktree后始终需要执行修复操作。
git worktree repair <path>.git/worktrees/<name>/gitdir.gitThe base ref
基准引用
Never assume . Repos default to , , and in the wild, and getting this wrong silently produces an empty or enormous diff. The ladder, in order:
maindeveloptrunkmaster- — authoritative when the GitHub CLI is available and authenticated.
gh repo view --json defaultBranchRef --jq .defaultBranchRef.name - — the local record, if it has been set.
git symbolic-ref --short refs/remotes/origin/HEAD - to repair an unset
git remote set-head origin --auto, then retry the previous step. This is the step most implementations skip, and it is the one that turns a failure into an answer.origin/HEAD - Whichever of /
origin/mainactually exists.origin/master - Ask the human. Do not guess past this point.
Everything downstream — , ahead/behind counts, the branch a worktree is cut from — uses the answer.
git diff <base>...HEAD绝不要假设是。实际环境中,仓库的默认分支可能是、或,若此处出错会静默生成空差异或巨大差异。优先级顺序如下:
maindeveloptrunkmaster- —— 当GitHub CLI可用且已认证时,这是权威来源。
gh repo view --json defaultBranchRef --jq .defaultBranchRef.name - —— 本地记录(如果已设置)。
git symbolic-ref --short refs/remotes/origin/HEAD - 修复未设置的
git remote set-head origin --auto,然后重试上一步。大多数实现会跳过此步骤,但这正是将失败转化为答案的关键。origin/HEAD - 实际存在的/
origin/main二者之一。origin/master - 询问用户。至此绝不能再猜测。
所有下游操作——、领先/落后计数、worktree基于哪个分支创建——都会使用此处的结果。
git diff <base>...HEADRebase or merge
变基还是合并
Syncing a feature branch with its base has one default here, and it does not depend on whether a pull request is open:
Rebase onto the base to sync a feature branch — published or not. Merging the base in is an exception that needs a stated reason and the user's consent.
The default is rebase because that is the history worth having: a feature branch that reads as a linear sequence of its own commits, with the base's work underneath rather than braided through it. A repo that merges the base in on every sync accumulates one merge commit per sync, and the branch's own story becomes unreadable long before it lands.
Rebasing does have a real cost, and it is mechanical rather than aesthetic: it rewrites commit SHAs. Once a pull request is open, its review threads are anchored to those commits, so a force-push marks every one of them outdated — human and bot findings alike. That is the cost to disclose and weigh, not a bar. It is also the one pre-baked reason to propose the merge exception.
In practice:
sh
git fetch origin
git rev-list --left-right --count "origin/$BASE"...HEAD # "<behind>\t<ahead>"; left > 0 means behind
git rebase "origin/$BASE"- Rebase is the answer unless someone has said otherwise for this branch. No pull request, an open one, a shared branch — the recommendation is the same.
- A branch with no remote counterpart rebases straight through. Nothing points at those SHAs, so nothing can break; this is the cheap-and-reversible class, and it needs no confirmation.
- A published branch previews once and waits. One confirmation covers the rebase and the push that follows — they are a single decision, and asking twice asks the same question twice. Name what it costs: the base being synced, the commits being rewritten, and the number of unresolved review threads that will go outdated.
--force-with-lease - Count the threads before you ask. On a branch with an open PR, query the GraphQL connection for unresolved threads and put the number in the preview. "3 review threads will be marked outdated" is a fact the user can decide on; "this may outdate review comments" is not.
reviewThreads - Unresolved threads are the reason to offer the merge exception — not to take it. Still recommend the rebase; name merge as the available alternative alongside the count. A preference that folds in the case that argues against it was never a preference.
- , never bare
--force-with-lease— the lease is what stops you overwriting a commit someone else pushed while you were rebasing.--force - On conflict, stop and surface it (). Propose a resolution per file and confirm before writing. A conflict resolution is a code change: run the repo's test gate afterward.
git diff --name-only --diff-filter=U
将功能分支与基准分支同步有一个默认规则,且与PR是否打开无关:
将功能分支变基到基准分支以实现同步——无论该分支是否已发布。将基准分支合并进来是例外情况,需要明确的理由和用户的同意。
默认选择变基是因为这样能生成更有价值的提交历史:功能分支的提交呈现为线性序列,基准分支的工作位于其下方而非交织在一起。每次同步都合并基准分支的仓库会积累大量合并提交,分支自身的提交历史在合并前就会变得难以阅读。
变基确实存在实际成本,且是机械性的而非美学性的:它会重写提交SHA。一旦PR打开,审查线程会锚定到这些提交,因此强制推送会标记所有线程为过时——包括人工和机器人的审查结果。这是需要披露和权衡的成本,而非障碍。这也是唯一预先设定的、可建议合并例外情况的理由。
实际操作:
sh
git fetch origin
git rev-list --left-right --count "origin/$BASE"...HEAD # "<落后数>\t<领先数>"; 左侧数值>0表示落后
git rebase "origin/$BASE"- 除非有人针对该分支另有说明,否则默认选择变基。无论是否有PR、PR是否打开、是否为共享分支,推荐规则均相同。
- 无远程对应分支的分支可直接变基。没有任何内容指向这些SHA,因此不会破坏任何东西;这属于低成本且可逆的操作,无需确认。
- 已发布的分支会先预览,然后等待确认。一次确认涵盖变基操作以及后续的推送——这是一个单一决策,询问两次相当于重复提问。需明确说明成本:同步的基准分支、将被重写的提交数量,以及将被标记为过时的未解决审查线程数量。
--force-with-lease - 询问前先统计线程数量。对于PR已打开的分支,查询GraphQL的连接获取未解决线程的数量,并将其包含在预览中。“3条审查线程将被标记为过时”是用户可以据此决策的事实;“这可能会使审查评论过时”则不是。
reviewThreads - 未解决线程是提供合并例外选项的理由——而非直接选择合并。仍推荐变基;同时列出合并作为可用替代方案及线程数量。如果一个偏好会涵盖与之相悖的情况,那它就不是真正的偏好。
- 使用,绝不要使用裸
--force-with-lease——lease机制可防止你在变基期间覆盖他人推送的提交。--force - 发生冲突时,停止操作并显示冲突内容()。针对每个文件提出解决方案,确认后再执行。冲突解决属于代码变更:之后需运行仓库的测试门限。
git diff --name-only --diff-filter=U
The merge exception
合并例外情况
When the user takes the merge — or asks for it outright — it is still a sync, and it says so:
sh
git merge "origin/$BASE" -m "chore(repo): sync with origin $BASE"- Never git's default subject. is what git writes when nobody chose a message, and it reads that way forever in
Merge branch 'main' into issue-42-tailwind-4-foundation. The fixed subject is the message.git log - Interpolate the base, don't hardcode . The base ref ladder exists because
mainanddeveloprepos are real; a subject that saystrunkin one of them is simply false.main - No . If the sync can fast-forward, the branch had nothing of its own to preserve and git writes no commit at all — there is no subject to fix, and forcing one manufactures an empty merge commit.
--no-ff - State the reason in the same breath as the ask. "Merging instead of rebasing because this PR has 3 unresolved review threads" is a reason. "Merging to be safe" is not; if you cannot name what rebasing would break, rebase.
当用户选择合并——或直接要求合并时,这仍然是同步操作,需明确说明:
sh
git merge "origin/$BASE" -m "chore(repo): sync with origin $BASE"- 绝不要使用Git默认的提交主题。是无人选择提交信息时Git自动生成的内容,会永久保留在
Merge branch 'main' into issue-42-tailwind-4-foundation中,显得非常随意。应使用固定的提交主题。git log - 插入基准分支名称,不要硬编码。基准引用的优先级顺序存在的原因是
main和develop仓库是真实存在的;在这些仓库中,提交主题写trunk是完全错误的。main - 不要使用。如果同步可以快进,则分支自身没有需要保留的内容,Git不会生成任何提交——无需修复主题,强制生成提交会制造空的合并提交。
--no-ff - 提出请求的同时说明理由。“由于此PR有3条未解决审查线程,因此选择合并而非变基”是合理理由。“为了安全选择合并”则不是;如果你无法说明变基会破坏什么,就应该选择变基。
Never bare git pull
git pull绝不要使用裸git pull
git pullgit pullMerge branch 'main' of github.com:owner/repogit pull --rebasegit pull --ff-onlygit pull在落后于远程分支的分支上执行会默认合并,并在未询问任何人的情况下生成的提交信息。应使用,或在希望同步失败时使用。刷新基准分支本身时调用也是如此——配置它或传递参数,但绝不要使用默认行为。
git pullMerge branch 'main' of github.com:owner/repogit pull --rebasegit pull --ff-onlygit pullContainers and remote boxes
容器与远程服务器
Git worktrees store absolute paths. If a repo is bind-mounted into a container at a path different from the host's, every worktree inside it breaks.
- Mount both and the main checkout. A worktree's real git directory lives under the main repo's
$WORKTREE_ROOT; mounting only the worktree yields a broken checkout..git/worktrees/ - Mount both at the same absolute path inside and outside the container. This is the robust answer.
- Second belt, on git 2.48+: and
git config worktree.useRelativePaths true. Relative pointers survive remapping as long as the repo and the worktree root keep their relative positions — which argues for siding them, e.g.git worktree repair --relative-pathsand~/code/<repo>.~/worktrees/<repo>
A GUI dev tool that manages worktrees is welcome to observe these — Orca and its peers read and typically have a setting to surface externally-created worktrees. That is a one-time UI configuration on whichever machine runs the GUI, and it is the only asymmetry between machines.
git worktree listNo skill may create or remove a worktree through a vendor CLI: the moment one does, the two machines diverge. A vendor's own metadata about a worktree — the issue its card links to, a status, a comment — is a different layer and is fair game, because it exists only inside that tool and has no git equivalent to diverge from. A companion skill may reconcile that layer (orcakit does, for Orca) as long as the worktree itself is still created and destroyed here. gitkit never calls in that direction: it must keep working on a machine where no such tool is installed.
Git worktree存储绝对路径。如果仓库被绑定挂载到容器中的路径与主机不同,其中的所有worktree都会失效。
- 同时挂载**和主仓库**。worktree的真实Git目录位于主仓库的
$WORKTREE_ROOT下;仅挂载worktree会导致检出失败。.git/worktrees/ - 在容器内外使用相同的绝对路径挂载。这是最可靠的解决方案。
- 备选方案(Git 2.48+):和
git config worktree.useRelativePaths true。相对指针在仓库和worktree根目录保持相对位置时可存活——这建议将它们放在一起,例如git worktree repair --relative-paths和~/code/<repo>。~/worktrees/<repo>
管理worktree的GUI开发工具可以遵循这些规则——Orca及其同类工具会读取,通常有设置可显示外部创建的worktree。这是运行GUI的机器上的一次性UI配置,也是机器之间唯一的不对称性。
git worktree list任何技能都不得通过厂商CLI创建或删除worktree:一旦这样做,两台机器就会产生差异。厂商关于worktree的元数据——其卡片链接的任务、状态、评论——属于不同层级,是允许的,因为它仅存在于该工具内部,没有对应的Git内容会产生差异。配套技能可以协调该层级(Orcakit针对Orca会这样做),只要worktree本身仍在此处创建和删除。gitkit绝不会向该方向调用:它必须在未安装此类工具的机器上也能正常工作。
Notes
注意事项
- gitkit is the single source of truth for what it owns. A calling skill may hold policy about when to ask — that a PR is worth pulling down, that a branch is ready to publish — but never about how the git operation is done. If you find a worktree path, base-ref ladder, or rebase rule restated inside another skill, that is the bug.
- gitkit never implements, commits, or opens anything. It prepares the ground and tears it down. Writing code in the worktree, committing, and publishing belong to other skills.
- Destructive steps preview and confirm. Removing a worktree, deleting a branch, and rebasing a published branch each show what is about to happen and wait for an OK. Creating, adopting, and rebasing an unpushed branch are cheap and reversible — those run straight through. The line is whether anything outside this machine points at what you are about to rewrite, not which command you typed.
- No shell available (e.g. a browser-based agent)? Then you cannot run git. Reason from what the user provides and print the exact commands as a codeblock for them to run — never report a worktree created or removed that you could not perform.
- gitkit是其所管理内容的唯一事实来源。调用它的技能可以制定何时调用的策略——比如PR值得拉取、分支已准备好发布——但绝不能制定如何执行Git操作的策略。如果在其他技能中发现worktree路径、基准引用优先级或变基规则被重复定义,那就是一个bug。
- gitkit从不实现、提交或打开任何内容。它只负责准备和清理工作环境。在worktree中编写代码、提交和发布属于其他技能的范畴。
- 破坏性操作会先预览并等待确认。删除worktree、删除分支、变基已发布分支都会显示即将执行的操作并等待确认。创建、采用和变基未推送的分支是低成本且可逆的——这些操作会直接执行。判断标准是是否有外部内容指向你即将重写的内容,而非你输入的命令。
- 无Shell可用(例如基于浏览器的Agent)?此时无法运行Git。根据用户提供的信息进行推理,并打印精确的命令作为代码块供用户执行——绝不要报告你无法执行的worktree创建或删除操作。