Git Worktree vs Branch: What Is the Difference?
A branch is a named pointer to a commit. A worktree is a directory with files checked out from a commit, usually a branch. You need a worktree only to have two branches open at the same time.
The Answer
A branch is a line of history. A worktree is a place to edit files. A normal clone has one worktree, so switching branches swaps the files in that one directory. git worktree add gives you a second directory, so two branches stay checked out side by side.
| Branch | Worktree | |
|---|---|---|
| What it is | A ref under refs/heads/ that points at a commit | A directory with its own files, index and HEAD |
| Created with | git branch feature or git switch -c feature | git worktree add ../repo-feature feature |
| Cost | A few bytes | A full copy of the tracked files |
| Shared across worktrees | Yes, every worktree sees every branch | No, each worktree has its own uncommitted changes |
| Removed with | git branch -d feature | git worktree remove ../repo-feature |
Use a branch alone when you work on one thing at a time and switching is cheap. Add a worktree when you need two branches live at once: a long build on one while you edit another, a hotfix without stashing, or two coding agents that must not edit the same files.
How They Relate
Each worktree has one HEAD. It points at a branch, or at a commit when detached. git branch -vv marks branches that another worktree holds with + and shows its path:
+ feature 54d33c8 (/src/repo-feature) init
* main 54d33c8 init
+ new-feature 54d33c8 (/src/repo-new-feature) init
Git lets one branch be checked out in only one worktree. Trying a second checkout fails:
fatal: 'feature' is already used by worktree at '/src/repo-feature'
The two lifecycles are separate. Removing a worktree leaves its branch in place, and Git refuses to delete a branch that a worktree still uses:
error: cannot delete branch 'hotfix' used by worktree at '/src/repo-hotfix'
Inside a worktree you can still switch or create branches. git switch -c other changes which branch that directory holds without affecting any other worktree.
How Treq Handles It
Treq pairs the two for you. Each workspace gets its own branch and its own working copy under .treq/workspaces/, so one task maps to one branch and one directory. Treq uses its own managed workspaces, not Git worktrees, which lets it rebase stacked workspace branches when their targets move.