Parallel Branches With git worktree

Check out a second branch into a separate directory sharing one repository.

macOSgitcliproductivityLow risk
Run git worktree add ../hotfix hotfix to create a linked checkout of that branch.

01Command

Command
$ git worktree add ../hotfix hotfix

02What 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

RiskLow risk
RequirementsGit 2.20+ (install with Homebrew or Xcode Command Line Tools)
CompatibilitymacOS with Git installed (Homebrew or Xcode Command Line Tools)
!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 documentation
    Git · vendor-doc · 2026-09-20
    Evidence: Documents git worktree, which attaches multiple working trees to one repository.

Last verified: 2026-10-13 · Category: Developer

06Related solutions