Parallel Branches With git worktree
Check out a second branch into a separate directory sharing one repository.
Run git worktree add ../hotfix hotfix to create a linked checkout of that branch.
01Command
Command
$ git worktree add ../hotfix hotfix02What it does
A linked worktree shares the object database and refs of the main clone, so a hotfix or review branch can be built and tested in a separate folder without disturbing the current checkout. It avoids re-cloning large repositories, which saves time and disk.
03Risk
!Warning: Removing a worktree directory manually leaves stale metadata; use git worktree remove instead.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- git-worktree documentationEvidence: Documents git worktree, which attaches multiple working trees to one repository.
Last verified: 2026-10-13 · Category: Developer