Key takeaways
- 01Every developer knows the context-switching tax: you are halfway through a refactor with twelve modified files, a running dev server, and a failing test when an urgent hotfix or pull-request review lands. Traditional Git forces a bad choice — either bury your half-finished work in
git stash(and pray nothing conflicts when you pop it) or clone the entire repository a second time, wasting gigabytes of disk space and duplicating remote history. - 02Worktrees turn branch switching from a destructive pause into parallel directories. Pair Worktrunk with dedicated branches per task — especially for AI coding agents — and your
maincheckout stays clean.
Why this tool matters
Git already has a built-in solution called git worktree, which links multiple independent working folders to a single .git database. The problem is ergonomics: vanilla git worktree commands are verbose, make you manually invent sibling paths, and do not help you switch directories or clean up merged branches.
Worktrunk (wt) is a fast Rust CLI that wraps Git worktrees in a single ergonomic workflow. It shines especially when you run multiple AI coding agents in parallel — one agent can edit a UI branch while your main checkout stays clean for reviews or production hotfixes.
Watch the walkthrough
How Git worktrees and Worktrunk work under the hood
In a standard Git clone, .git is a directory containing both the shared repository history (objects/, refs/, config) and the per-checkout state (HEAD and the staging index). When Worktrunk creates a linked worktree, it does not copy the object database.
Instead, the new folder receives a tiny .git text file pointing back to <main-repo>/.git/worktrees/<name>, where Git stores an isolated HEAD and staging index. Commits made in one worktree are immediately visible to every other worktree, while uncommitted edits remain completely isolated on disk.
- No duplicate Git history: every worktree shares one object database, so a second checkout only adds its working files on disk, not another copy of the repository history.
- The Branch Lock Rule: Git forbids checking out the exact same branch in two worktrees simultaneously to prevent conflicting
HEADupdates. Worktrunk handles this cleanly by creating or switching to a distinct branch per folder. - Parallel dev servers & AI agents: you can open two terminal windows or two IDE workspaces — one on
main, one onui-test— without invalidating build caches or interrupting running processes. - Portable Windows binary: Worktrunk ships as a standalone
wt.exeexecutable with zero runtime dependencies.
How it compares to alternatives
| Tool | Best for | Main tradeoff |
|---|---|---|
| Worktrunk (wt) | Developers and AI-assisted workflows that spin up and tear down parallel branches daily. | Extra CLI tool to install; note that wt collides with Windows Terminal's wt.exe alias unless you invoke the explicit path or alias it. |
| Vanilla git worktree | Occasional parallel checkouts with zero third-party tools. | Verbose syntax (git worktree add -b ... ../path), manual directory naming, and manual cleanup/pruning. |
| git stash + git switch | Quick 30-second branch switches with tiny diffs. | Destroys running dev-server state, triggers full rebuilds, and risks losing untracked files or stash conflicts. |
| Multiple full git clones | Complete isolation when you want separate Git configs or remotes. | Duplicates the entire .git history on disk and forces you to push/fetch to share local commits between folders. |
Step-by-step walkthrough
Verify the portable Windows executable (avoiding Windows Terminal collision)
On Windows 11, typing bare
wtin PowerShell usually launches Windows Terminal rather than Worktrunk. Download the x64 Windows release archive from GitHub, extractwt.exe, and bind its full path to$wtin your PowerShell session (or rename/alias it towtron your PATH). This guide was verified with Worktrunk v0.83.0.- Confirming
& $wt --versionprints the Worktrunk version proves you are invoking the right binary and not Windows Terminal.
$wt = (Get-Item .\wt.exe).FullName & $wt --version- Confirming
Initialize an isolated scratch repository
Create a fresh folder called
git-laband make a single initial commit. Passing-c user.nameand-c user.emailscopes the commit metadata to this command only, leaving your global~/.gitconfiguntouched. Git requires at least one commit onmainbefore creating linked worktrees.- Using
-b mainensures consistent default branch naming regardless of your localinit.defaultBranchsetting.
New-Item -ItemType Directory -Path git-lab | Out-Null Set-Location git-lab git init -b main Set-Content README.md '# Worktree lab' git add README.md git -c user.name=Demo -c user.email=demo@example.invalid commit -m 'Start lab'- Using
Create a linked worktree with Worktrunk
Run
wt switch --create ui-testwith--no-hooksand an explicit sibling--path. Worktrunk creates theui-testbranch, checks it out into../git-lab-ui-test, and registers it in Git's worktree list. Because a child executable cannot change the parent PowerShell working directory without shell integration, useSet-Locationwhenever you want to enter the new folder.& $wt listandgit worktree listboth display every linked checkout, its active branch, and its current HEAD commit.- If you use Worktrunk daily, run
wt config shell installto enable automatic directory switching.
& $wt switch --create ui-test --no-hooks --path ../git-lab-ui-test & $wt list git worktree listVerify independent working trees and clean up safely
Modify
README.mdinside../git-lab-ui-testand inspectgit status --shortin both directories. Theui-testfolder reportsM README.md, while your primarygit-labfolder onmainremains completely clean. When you finish with a worktree, remove it cleanly rather than just deleting the folder so Git unlocks the branch immediately.- If you ever delete a worktree folder manually in Explorer, run
git worktree prunefrommainto remove stale metadata. - Remember that untracked folders like
node_modulesor.venvare not shared automatically — install or symlink them per worktree as needed.
Add-Content ../git-lab-ui-test/README.md 'Preview note' git -C ../git-lab-ui-test status --short git status --short # When finished: # git worktree remove ../git-lab-ui-test --force- If you ever delete a worktree folder manually in Explorer, run
Worktrees turn branch switching from a destructive pause into parallel directories. Pair Worktrunk with dedicated branches per task — especially for AI coding agents — and your main checkout stays clean.
Common pitfalls
Windows Terminal hijacking the `wt` command
Windows ships wt.exe in WindowsApps for Windows Terminal. Always check Get-Command wt and either alias Worktrunk (e.g. wtr) or disable the Windows Terminal execution alias in Settings → Apps → App execution aliases.
Forgetting `.env` and `node_modules` in the new worktree
Because ignored files are not tracked by Git, your new worktree starts without .env.local or node_modules. Copy .env or use Worktrunk's post-create hook to automate setup.
Trying to check out `main` in two folders at once
Git blocks checking out the same branch twice. Create a dedicated feature or review branch (or detached HEAD) for every extra worktree.
Frequently asked questions
- Why use Worktrunk with AI coding agents like Claude Code or Codex?
- Running each coding agent in its own worktree prevents agents from overwriting each other's uncommitted files and lets you review diffs cleanly on separate branches before merging.
- Does a worktree duplicate my entire Git history on disk?
- No. All worktrees share the single `.git/objects` store. Only the checked-out working files (and any local dependencies you install) occupy extra disk space.
- What happens if I commit inside `ui-test` — does `main` see it?
- The commit immediately enters the shared `.git` database on branch `ui-test`, so you can run `git merge ui-test` or `git diff main..ui-test` from `main` without pushing or fetching.
Sources and methodology
Every command in this guide was run on a clean Windows machine before publishing, and the video shows that run. Versions are pinned where the project publishes them, so the output you see should match ours.
