Files
cindy/apps/desktop/help-knowledge/worktrees.md
Dash e75a59a984 feat(worktree): 新建 Worktree 使用 Cindy 分支命名空间 (#1682)
* feat(worktree): adopt Cindy branch namespace

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(worktree): distinguish branch ref namespaces

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(worktree): preserve non-managed branch identity

Signed-off-by: Dash <dashhuang@gmail.com>

---------

Signed-off-by: Dash <dashhuang@gmail.com>
2026-08-05 04:45:15 +08:00

2.6 KiB

id, title, summary
id title summary
worktrees Working in an isolated git worktree Opt a session into an isolated git worktree so its changes stay on their own branch and folder.

A session can run inside its own git worktree — a separate working copy of the same repository on its own branch — so the agent's edits don't mix with your main checkout.

Opting in:

  • In the new-chat view, click the working-directory chip → the gear icon to open the Advanced popover → tick the worktree checkbox.
  • The worktree is created on first message send, not on session create. An overlay shows the status (creating / ready / failed).

Where it goes:

  • Folder: <repo>/.cindy-worktrees/<auto-generated-name>/ — kept inside the same repo so git tooling can find it. Worktrees created by older versions under .xdt-worktrees/ remain supported.
  • Branch: cindy/<auto-generated-name> — auto-created off the source branch you pick, which defaults to the repo's current branch (HEAD). Branches created by older versions under xdt/ remain supported and do not need to be renamed.

Lifecycle:

  • Created on first agent turn that needs files.
  • Survives across app restarts as long as the session is around. Transient closes (/clear, reconnecting, quitting the app) do not remove it.
  • The folder is removed only when you explicitly delete or archive the session; the branch is preserved (no force-delete), so you can keep the work or merge / cherry-pick from it later.
  • Uncommitted changes inside the worktree are auto-stashed before the folder is removed, so nothing is silently lost. Removal is also skipped if you leave a .worktree-keep file in it or another live session is still using it.

When the option is disabled:

  • Git is not installed on your machine.
  • The chosen working directory isn't a git repository.
  • The chosen directory is already inside an existing worktree (no nesting).

Error cases (shown on the overlay):

  • permission-denied (can't write into the repo dir), git-crypt-locked (repo uses git-crypt and isn't unlocked), dubious-ownership (git's safe.directory check tripped), lfs-error, not-a-git-repo, git-not-installed.

Notes:

  • The agent's Read / Write / Bash tools automatically operate inside the worktree path — you don't need to switch directories manually.
  • Because the branch survives the worktree, "did the agent's changes go anywhere?" is always answerable with git branch --list 'cindy/*' 'xdt/*'.
  • Worktrees are a per-session opt-in — they're not on by default and they don't change non-worktree sessions in any way.