dsh-fork-worktree: Fork a git worktree from the working directory

Preface

In DeepSeek Harness (DSH), the sidebar lists multiple workspaces, where each workspace corresponds to a directory and a session. When you want to test different changes in parallel on the same repository, or want to keep a “clean checkout” without manually typing git worktree, you usually have to keep track of directory naming and branch names yourself, and then register the new path in DSH again.

dsh-fork-worktree integrates this directly into the workspace row: it adds two buttons between … and +, completing the fork or deletion via a confirmation dialog, and opening a new session or cleaning up the registration upon success. Below is an introduction to what it does, how to install and use it, and the boundary conditions to be aware of.

What is this

dsh-fork-worktree is a community-maintained DSH plugin (maintainer Bainianzzz), categorized as Workflow. It adds fork and trash actions to each workspace entry in the sidebar: the former creates a worktree based on the git repository corresponding to the current workspace directory and registers it as a new workspace; the latter deletes the worktree for that workspace and removes the registration. The plugin is released under the MIT license. The current package version is 0.2.1, requiring DSH >=0.2.1-rc.2 <0.3.0.

Directory Page: skillhub.cn/plugins/Bainianzzz/dsh-fork-worktree
Source Code & Docs: github.com/Bainianzzz/dsh-fork-worktree

Core Features

Two buttons on the workspace row

After installation and enabling, hovering over a workspace row reveals:

  • fork: Forks a new git worktree from this workspace, registers it as a new workspace, and opens a session in the new workspace.
  • trash: Deletes the worktree corresponding to this workspace and removes the workspace registration.

Both actions trigger a confirmation dialog first; simply clicking the button does not execute the action directly.

fork: Two creation methods

In the confirmation dialog, you can choose:

  1. Create git worktree: Only checks out committed content; uncommitted changes, untracked files, and content ignored by .gitignore remain in the source directory.
  2. Copy and create worktree: After checkout, copies missing files from the source directory into the worktree, including untracked and ignored content (e.g., node_modules, .env, build artifacts, config files, etc.). Tracked files remain at the HEAD version; relative path symlinks are preserved as-is.

When the directory is already a git repository

After clicking either creation button:

  • Creates a directory <repo-name>-wt-<label> sibling to the repository.
  • The branch name is wt/<label>, based on the current HEAD.
  • If the copy method is selected, missing files are filled in, and it is registered as a new workspace.

When the directory is not yet a git repository

The dialog switches to “Initialize” mode (preserving your selected method). Upon confirming again, it executes git init, takes the current directory content as the first commit (or an empty commit if the directory is empty), and then creates the worktree.

On success, a session is opened in the new workspace, and a toast displays the path; for the copy method, it also indicates how many items were copied. If the copy fails, the newly created worktree and branch are rolled back together.

Delete worktree

  1. After clicking trash, the confirmation dialog specifies the path to be deleted and explains that session history will be preserved.
  2. After confirmation, it deletes the worktree via git worktree remove, cleans up repository worktree metadata, and removes the workspace registration.
  3. If there are uncommitted changes or untracked files, deletion is refused; the dialog switches to “Force Delete” mode, requiring confirmation to execute.
  4. Guardrails: Will not delete $HOME or the filesystem root directory.

Deletion deliberately does not have a slash command entry to prevent a single command from accidentally deleting a directory currently in use by the session.

Auto-cleanup

If a worktree directory is deleted externally in the filesystem, the corresponding workspace registration is automatically removed; normal directories and directories not conforming to the naming rules are unaffected.

Installation and Activation

Open the Plugins panel in the sidebar, click Add Plugin, and enter the line below (consistent with the README):

github:Bainianzzz/dsh-fork-worktree

Once installed, click Enable Now. After enabling, hover over a workspace row to see the fork and trash buttons. For more installation methods, see the repository’s Release Page.

The DSH ecosystem emphasizes “everything is a plugin”; community directories like SkillHub are independent sites and have no official affiliation with DeepSeek / High-Flyer. The plugin executes git and file operations under the permissions of the current dsh process. Please review the source code and MIT license yourself before installation.

Typical Usage

  1. Select a workspace, click fork, choose “Create git worktree” or “Copy and create worktree” in the dialog, then click the corresponding creation button and confirm.
  2. When you need to dismantle a forked workspace, click trash, verify the path, and confirm; for dirty workspaces, follow the prompts for a force delete secondary confirmation.

In-session command (fork only)

You can execute the following in the session of that workspace:

/fork-worktree [name] [--init] [--copy]

When name is omitted, a 6-digit random hex is used as the label; --copy corresponds to “Copy and create worktree”. For non-git directories, --init can be used with the initialization flow (consistent with the sidebar “Initialize” mode).

Applicable Scenarios & Cautions

Suitable for scenarios where you need to open multiple parallel workspaces on the same repository, or quickly copy the current directory (including local uncommitted/ignored files) to a new worktree to continue the conversation. If you only want a pure HEAD checkout and want uncommitted changes in the source directory to be completely isolated, simply choose “Create git worktree”.

Notes:

  • The copy method brings along ignored files like node_modules and .env. Please ensure no sensitive information is mistakenly copied to the new directory.
  • Deletion affects real directories and git worktree metadata; force delete can clear worktrees with uncommitted changes. Check the path in the confirmation dialog carefully before operating.
  • The engine version must fall within >=0.2.1-rc.2 <0.3.0. If it does not match the current DSH, please upgrade or switch to a compatible version first.

Conclusion

dsh-fork-worktree binds the creation and cleanup of git worktrees to the DSH workspace row, reducing manual path copying and duplicate registration. For details and updates, refer to the GitHub README: Bainianzzz/dsh-fork-worktree; you can also access it via the directory page: skillhub.cn/plugins/Bainianzzz/dsh-fork-worktree.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye