When developing agents in DSH, it is often necessary to advance tasks in parallel on independent branches while preserving the context of the current conversation. Native DSH does not directly provide this level of git worktree management; the dsh-worktree plugin fills this gap.

Plugin Overview

dsh-worktree is a DSH workflow plugin developed by Jiazliang. Its core value is providing a git fork-like operation: it creates an isolated git worktree (an independent branch) for any workspace or session and opens a new session in it.

The plugin provides a complete “create → use → delete” closed loop. It supports session forking (inheriting conversation history), enabling parallel development without interference.

Core Features

1. Create an Independent Worktree

Click “Create Worktree” in the workspace menu to create an independent git worktree and an independent branch based on the current repository.

  • Directory isolation: The new workspace appears in the sidebar, and the current working directory (cwd) of the new session points to the <repo-name>.Worktree/<id> directory outside the repository.
  • Automatic opening: A new session opens automatically after creation, and that session uses the independent branch.
  • Zero interference: The .git directory of the main workspace is not touched, and the main repository’s git status remains clean.

2. Fork to Worktree

Click “Fork to Worktree” in the session menu to move into a new worktree with all the context of the current conversation.

  • History inheritance: The new session inherits the full conversation history of the current session.
  • Configuration inheritance: It inherits the preset and model settings used by the current session, without requiring reconfiguration.

3. Delete Worktree

For a worktree workspace created by the plugin, the menu includes an additional “Delete Worktree” item.

  • Forced teardown: Forcefully deletes the worktree directory and the corresponding branch, and removes the workspace registration.
  • Safety guardrail: This operation is shown only for worktree workspaces created by the plugin. Regular workspaces do not show this item, preventing accidental deletion of the main repository.
  • Data retention: Note that this operation discards uncommitted changes, but session logs are retained (consistent with DSH native behavior).

4. Compatibility and UI

  • Automatic adaptation: Preferentially uses the native menu slots in newer DSH versions; older builds automatically fall back to a DOM injection adapter.
  • Chinese interface: Menu items use Chinese naming, keeping symmetry with DSH built-in entries.

Installation and Enablement

Install it using the official plugin command:

dsh plugin --profile web add github:Jiazliang/dsh-worktree

After installation, you need to restart the dsh web application for the change to take effect.

Typical Usage

Scenario: branch off an independent development line from the main workspace

  1. Open the menu on a workspace (folder) in the sidebar and click “Create Worktree”;
  2. A new workspace appears in the sidebar, a new session opens automatically, and the working directory now points to the independent worktree (independent branch);
  3. Develop and commit in that session; all changes affect only that branch;
  4. If you need to start another line with the current conversation context, click “Fork to Worktree” in the session menu; the child session inherits the full history and lands on a new worktree;
  5. When the task is complete or the branch is no longer needed, click “Delete Worktree” in the menu of that worktree workspace; the directory and branch will be cleaned up.

Notes

  • Prerequisites: Creation requires that the target workspace is a git repository (the repository root must be resolvable from the cwd).
  • Deletion behavior: “Delete Worktree” is a destructive operation. Uncommitted changes are discarded with the directory deletion, but session logs are retained.
  • Path structure: The cwd of the new session points to the <repo-name>.Worktree/<id> directory outside the repository.

Conclusion

dsh-worktree adds Git Worktree capabilities to DSH through a plugin, making it suitable for developers who need to manage multiple branches and sessions in parallel within the same repository. For more details, see the plugin directory or the source repository.