Preface

When developing with DSH, it is common to handle multiple branches of the same project simultaneously: keeping main as the main branch, opening a branch for feature development, and another for fixing online issues. Git worktrees solve this pain point by checking out multiple branches of the same repository into different directories. However, using the command line requires remembering paths and parameters, and scattered paths on disk are hard to manage. The dsh-worktrees introduced below brings this into the DSH settings panel.

What is it

dsh-worktrees is a DSH plugin maintained by lwklbb, licensed under MIT, with the current version being 0.1.0. The positioning can be summarized in one sentence: centrally manage Git worktrees within the DSH settings panel—scanning Git repositories in the workspace, creating worktrees and adding them to DSH workspaces, supporting opening directories, deletion, and pruning.

The motivation given by the author in the README is to handle multiple branches of the same project in DSH simultaneously, such as keeping main for the main line, feature/order-export for feature development, and fix/login-redirect for fixing online issues, without having to stash back and forth or switch branches frequently.

Core Features

Settings Entry and Repository Scanning

After installation, the DSH settings panel gains a new “Worktrees” option. Implementation-wise, it is mounted via the settings.section slot with the id worktrees.

The page reads the current DSH Workspaces and scans:

  1. Identifies whether each workspace belongs to a Git repository;
  2. When a single repository is hit by multiple workspaces, only one copy is retained;
  3. Displays the repository root directory, the number of existing worktrees, and the number of branches.

Non-Git directories are silently ignored without errors; when Git is not installed or not in the PATH, the page will prompt that Git is unavailable.

Worktree List

After selecting a repository, the list displays the following for each worktree: directory name, full path, current branch, whether detached, whether it is the main worktree, clean/changed status, ahead/behind information, and whether it has been added to a DSH workspace.

Create Worktree

The creation area supports three modes. First select a mode, then fill in the directory name and branch/start point:

  1. New Branch: Executes git worktree add -b to create a new branch from the specified start point;
  2. Existing Branch/Reference: Executes git worktree add to checkout an existing branch to a separate directory;
  3. Detach: Executes git worktree add --detach to temporarily view a specific commit, tag, or remote reference without creating a local branch.

If the branch name is not filled in, the directory name is used as the branch name.

Join DSH Workspace after Creation

The creation form defaults to checking “Join DSH Workspace after creation”. Upon successful creation, the plugin calls DSH’s workspace interface to add the new directory to the left-side workspace, which can be opened directly. If you only want to create a Git worktree and don’t want to add it to DSH, simply uncheck it.

Open, Delete, and Prune

Each worktree has an “Open” button that opens the corresponding directory via DSH’s openPath.

Deletion is only allowed for non-main worktrees and uses Git’s built-in command:

git worktree remove <path>

It does not include --force by default; Git will reject it if there are uncommitted changes in the worktree. Check “Force Delete” if you are sure. The main worktree cannot be deleted.

The Prune button executes:

git worktree prune

Used to clean up records of worktrees that no longer exist.

Installation and Enablement

First, confirm the runtime environment: the plugin requires Node >= 20 and depends on the local Git command line. Before installing, you can run:

git --version

Confirm that Git is installed and git is in the PATH; the page will prompt that Git is unavailable if it cannot be found.

Then, execute in the plugin directory:

dsh plugin --profile web add .

The README also provides an example specifying a path:

dsh -- plugin --profile web add D:\desktop\plugins-test\dsh-worktrees

It is worth noting that the installation commands given in the materials are all for local path installation and do not provide commands for installing from a remote GitHub repository.

After installation, restart or refresh DSH, and you can see Worktrees in the settings panel.

Regarding dependencies, the plugin declares @deepseek-ai/cordis ^4.0.1, @deepseek-ai/dsh-host-webserver ^0.1.0-rc.6, @deepseek-ai/dsh-client-locale / dsh-client-runtime / ui-settings / ui-slots (all ^0.1.0-rc.6) and react ^18.2.0 via peerDependencies. They need to match the current DSH version.

Typical Usage

The three modes correspond to one reproducible example each from the README.

New Branch mode, creating a new feature branch from the main line:

Directory Name: feature-order-export
Mode: New Branch
Branch Name / Reference: feature/order-export
Start Point: HEAD or origin/main

Actual execution is similar to:

git worktree add -b feature/order-export ..\feature-order-export origin/main

Existing Branch/Reference mode, checking out an existing branch to a separate directory:

Directory Name: fix-login-redirect
Mode: Existing Branch / Reference
Branch Name / Reference: fix/login-redirect

Actual execution is similar to:

git worktree add ..\fix-login-redirect fix/login-redirect

Detach mode, temporarily viewing a specific tag without creating a local branch:

Directory Name: review-v1.2.0
Mode: Detach
Start Point: v1.2.0

Actual execution is similar to:

git worktree add --detach ..\review-v1.2.0 v1.2.0

After the above steps, the newly created worktree will appear in the left DSH workspace by default and can be opened directly for use.

Applicable Scenarios and Notes

Suitable for: Developers who need to develop in parallel across multiple branches in DSH and do not want to stash back and forth or manually type worktree commands.

Points to note:

  1. The plugin runs with the permissions of the current dsh process; it is recommended to check the source code and license (MIT © 2026 lwklbb) before installing;
  2. Deletion is not forced by default, and the plugin does not recursively delete directories. Deletion is handled uniformly by official Git commands, leaving it to Git to judge whether it is allowed;
  3. The scan only reads the paths of the current DSH Workspaces and does not actively scan the entire disk;
  4. The main worktree cannot be deleted.

A supplement at the implementation level: the host API is registered under /worktrees/api/*, including five interfaces: list (scanning Git repositories and worktrees in workspace paths), branches (listing repository branches), create, remove, and prune; lib/git.js is pure Node logic, responsible for parsing git worktree list --porcelain, filtering non-Git directories, validating directory names/branch names, and status summaries based on git status --porcelain=v1 -b.

Summary

What dsh-worktrees does is not complicated: it brings Git worktree scanning, creation, deletion, and pruning into the DSH settings panel, and connects newly created worktrees to the workspace. If you usually develop with multiple branches in parallel in DSH, you can give it a try.

  • GitHub: https://github.com/lwklbb/dsh-worktrees
  • Third-party community plugin directory entry: https://www.skillhub.cn/plugins/lwklbb/dsh-worktrees (The address comes from plugin clues and does not appear in README or package.json, please refer to actual access)