Worktrees

Work on multiple branches simultaneously

Worktrees let you check out multiple branches simultaneously in separate directories, all linked to the same repo.

You are working on a feature but need to review a PR or fix a bug on another branch. Stashing is messy.

Worktrees
~/myapp
featureediting...
All worktrees share one .git directory
Commits, branches, and config are shared
Terminal
# Traditional approach (messy):
$ git stash           # save WIP
$ git checkout main   # switch branch
# ... do the work ...
$ git checkout feature # switch back
$ git stash pop       # restore WIP

# With worktrees:
# No stashing, no switching needed
# Work on multiple branches at once