Skip to main content
A worktree is an extra clone of the current repository, with its own workspace, in another directory. Run these commands from inside a clone. For how worktrees work, see Worktrees.

add

Creates a new workspace of this repository and clones it into path. Give at least one of path, -b, or --ref. [path] is where to create the worktree. A single name, like my-task, creates diversion-worktrees/<repo>/my-task next to the current clone. The path cannot be inside the current clone. Without -b or --ref, the worktree is on the branch named after the last part of the path, and that branch is created from the current commit if it does not exist. With -b or --ref and no path, the directory is named after the branch or commit. [-b <branch>] creates a new branch for the worktree, from --ref or from the current commit. Fails if the branch exists. [--ref <ref>] checks out a branch name, branch ID, commit ID, or tag ID. With -b, it is where the new branch starts. [--link] symlinks the dirs listed under link: in the repository’s .dvworktree.yml from the current clone, so the worktree shares them instead of building its own. [--setup] runs the setup: command from the repository’s .dvworktree.yml in the new worktree. The command gets the current clone’s path in the DV_WORKTREE_ORIGIN environment variable. Use it only with refs you trust.

list

Lists the worktrees of this repository on this computer, with their path, branch, and workspace ID.

remove

Deletes the worktree’s workspace, stops syncing its directory, and deletes the directory. It does not remove a main clone; for that, use unregister. Without -f, it first rescans the worktree and waits for the sync. It then refuses if the worktree has uncommitted changes, conflicts, conflict backups, or a submodule, or if the worktree is paused. For changes and backups, the error is:
[-f] removes the worktree anyway and deletes its uncommitted changes.