LaoYueHanNi/dsh-git-worktree
在 Web 输入框切换分支、以真实工作区方式创建隔离的 git worktree。
已收录
1
Git
Bundle 已验证
预览
功能介绍
在 Web 输入框切换分支、以真实工作区方式创建隔离的 git worktree。
适合
- 经常需要从 DSH Web 输入区切换 Git 分支的开发者。
- 需要把隔离分支作为真实 DSH 工作区使用的并行开发流程。
- 希望复用已有 worktree,并自动恢复陈旧注册信息的用户。
不适合
- 非 Git 项目,或不使用 DSH Web profile 的工作流。
- 已完全在 Web UI 外管理分支和 worktree、无需输入区分支选择器的用户。
- 要求卸载插件时同时删除 worktree 目录的环境;保留的目录需要手动清理。
README
dsh-git-worktree

| 简体中文 | English |
A dsh plugin for simple branch & worktree management in the Web UI. The composer tool row shows the current branch: pick another to switch in place, or flip the Worktree toggle to get an isolated worktree as a real workspace — as shown in the screenshot above.
Repo: https://github.com/LaoYueHanNi/dsh-git-worktree
Features
-
IDEA-style branch picker: the branch menu treats
/as a folder hierarchy — collapsible folders, last-segment labels, the checked-out branch’s chain opens by default and is centered on open. Single click selects a row; double-click or Enter opens the right-side confirm flyout. The left tool strip offers locate current branch and expand/collapse all; the bottom search keeps the matching branches’ ancestor folders and highlights the hit substring. Clipped labels expose the full name on hover. -
Branch switching: pick a branch from the chip’s menu and confirm — an in-place
git switch. Inside a linked worktree it switches within that worktree only. -
Worktree isolation: on a blank session, the Worktree toggle turns the pick into
git worktree addunder~/.dsh/gitworktree/<repo>-<branch>/, registered as a real workspace with a fresh blank session. Same branch re-picks reuse the existing worktree; stale registrations recover viagit worktree prune. - Storage root configurable: Settings → Git Worktree — native folder picker, saves automatically.
Install
From GitHub (recommended)
dsh plugin --profile web add github:LaoYueHanNi/dsh-git-worktree
The package declares
dsh.bundle, soaddwires the plugin into the profile’s layer stack automatically — no config editing needed. The builtlib/ships in the repo (there is nopreparescript), so git installs work out of the box without any build allowlist. Requires thewebprofile (dsh web).
From a local directory (development)
dsh plugin --profile web add link:D:/Code/dsh-worktree
link: installs a symlink: rebuild the plugin and restart dsh web to apply changes.
Update
dsh plugin --profile web update dsh-git-worktree
Remove
dsh plugin --profile web remove dsh-git-worktree
The plugin is removed from the profile and stops loading. Worktree folders under ~/.dsh/gitworktree/ and the settings file are kept — delete them manually if you no longer need them.
Development
Build the plugin once:
npm install
npm run build && npm run build:client
npm test # vitest (41 tests)
node scripts/smoke.mjs # real-git smoke over the built lib
No
preparescript — by design. The compiledlib/output is committed to the repo. pnpm ≥ 10 refuses to run build scripts of git-hosted dependencies unless they are allowlisted (ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED), so apreparescript would break the zero-configgithub:install for every user. Shipping prebuilt output instead keepsdsh plugin add github:LaoYueHanNi/dsh-git-worktreeworking out of the box. After changing anything undersrc/, always rebuild and commit the updatedlib/, or installs will get stale output:
npm run build && npm run build:client
git add lib/
Temporary mount — effective for this launch only, no profile changes. Create a cordis.yml next to the repo pointing at the built host half (Windows needs the file:/// form):
- insert:
- id: git-worktree
name: 'file:///D:/Code/dsh-worktree/lib/index.js'
dsh web --patch <plugin-dir>/cordis.yml
This mode only mounts the host half (the four /plugin/git-worktree/* routes keep working); the chip needs the client bundle resolved by package name, so for UI development use the link: install above instead: run npm run build && npm run build:client (or npx tsdown --watch in the plugin directory), restart dsh web, and the browser plugin hot-reloads automatically.
常见问题常见问题
在启用了 DSH 的终端中执行已验证命令 dsh plugin --profile default add github:LaoYueHanNi/dsh-git-worktree。命令会解析公开 package 元数据,并保持插件与本页展示的目录身份一致。
兼容性以页面上展示的 bundle 与 profile 状态为准。如果某个 profile 尚未检测到,请先保持禁用,并在生产启用前阅读仓库文档。
GitHub 链接和 activity 元数据是 release 与维护状态的来源。新版本发布后重新查看本页,确认目录已经观察到最新版本。