Day 18advancedFeb 18, 2026

Work on Multiple Branches Simultaneously with Git Worktrees

Git worktrees let you work on multiple branches at once without stashing or cloning.

gitproductivityadvanced
Share:

What

Git worktrees let you check out multiple branches at the same time in separate directories, without cloning the repo again. Each worktree shares the same .git history but has its own working directory. This means you can have your main branch open in one directory while working on a feature in another.

Why It Matters

Context switching between branches is expensive. You lose your place, have to stash changes, and risk merge conflicts with uncommitted work. Worktrees eliminate this by giving each branch its own directory. Review a PR in one worktree while continuing development in another β€” no stashing required.

Example

# Add a new worktree for a feature branch
git worktree add ../feature-branch feature-branch

# Add a worktree for a new branch
git worktree add -b hotfix-123 ../hotfix-123 main

# List all active worktrees
git worktree list

# Remove a worktree when done
git worktree remove ../feature-branch

# Prune stale worktree references
git worktree prune
bash

Common Mistake

Forgetting to remove worktrees after you're done, leaving stale references and consuming disk space. Also, trying to check out the same branch in two worktrees β€” Git prevents this to avoid conflicts.

Quick Fix

Run git worktree list regularly to see active worktrees. When finished with a branch, always clean up with git worktree remove <path>. Use git worktree prune to clean up references to deleted directories.

Key Takeaways

  • 1git worktree add <path> <branch> creates a linked working directory
  • 2Each worktree has its own working directory but shares Git history
  • 3No stashing needed β€” just switch directories
  • 4Cannot check out the same branch in two worktrees
  • 5Always clean up with git worktree remove when done

Was this tip helpful?

Help us improve the DevOpsPath daily collection

Share: