Skip to main content
The wit worktree command lets you check out multiple branches simultaneously in separate directories. This is useful when you need to work on different branches without constantly switching.

Overview

Worktrees allow you to:
  • Work on a feature while also working on a hotfix
  • Compare different branches side by side
  • Run tests on one branch while developing on another
  • Avoid stashing/committing in-progress work when switching contexts

Commands

add

Create a new worktree for a branch.

Arguments

Examples

Example Output


list

List all worktrees for the repository.

Example Output


remove

Remove a worktree.

Arguments

Examples

Removing a worktree deletes the working directory but does not delete the branch.

prune

Remove stale worktree entries.
Removes worktree entries where the directory no longer exists (e.g., was manually deleted).

Example Output


Use Cases

Hotfix While Developing

You’re working on a feature when an urgent bug needs fixing:

Side-by-Side Comparison

Compare code across branches:

Run Tests While Developing

Run tests on one branch while continuing to develop:

Code Review

Review a colleague’s PR without switching branches:

Best Practices

Keep worktrees as siblings to your main project:
This keeps them organized and easy to find.
Use clear names that indicate purpose:
Remove worktrees you’re no longer using:
Periodically check for forgotten worktrees:
Old worktrees take up disk space and can be confusing.

How Worktrees Work

Shared Objects

All worktrees share the same .wit (or .git) directory:
This means:
  • Objects, refs, and history are shared (saves disk space)
  • Commits made in any worktree are immediately visible to all
  • Each worktree has its own index and HEAD

Linked vs Main Worktree

  • Main worktree: The original directory where you cloned/initialized
  • Linked worktrees: Additional worktrees created with wit worktree add
The main worktree cannot be removed with wit worktree remove.

Comparison with Other Approaches


Troubleshooting

If you see “fatal: ‘branch’ is already checked out”:
A branch can only be checked out in one worktree at a time.
If the target directory already exists:
If you deleted a worktree directory manually:
If wit worktree remove fails due to uncommitted changes: