What are Worktrees?
A worktree is a separate working directory linked to the same repository. Each worktree can have a different branch checked out, enabling you to:- Work on multiple features simultaneously
- Review pull requests without disrupting your current work
- Run tests on one branch while developing on another
- Quickly switch between branches without stashing
Available Commands
| Command | Description |
|---|---|
repo wt add <branch> | Create a new worktree for a branch |
repo wt list | List all worktrees in the repository |
repo wt go <branch> | Navigate to a worktree |
repo wt rm <branch> | Remove a worktree |
repo wt pr <number> | Create a worktree for a pull request |
repo wt clean | Remove all worktrees except default branch |
Common Workflows
Working on a New Feature
Reviewing a Pull Request
Managing Multiple Tasks
Worktree Structure
Worktrees are organized within your repository root:- Checked out files
- Index (staging area)
- Current branch
Best Practices
- Default Branch Protection: The default branch worktree (main/master) cannot be removed
- Clean Regularly: Use
repo wt cleanto remove unused worktrees - Commit Before Removing: Worktrees with uncommitted changes cannot be removed
- Unique Branches: Each worktree must use a different branch
- Navigate with
go: Userepo wt goinstead of manualcdfor proper setup
Next Steps
- Add Worktrees - Create new worktrees
- List Worktrees - View all worktrees
- Navigate Worktrees - Switch between worktrees
- Remove Worktrees - Delete worktrees
- PR Worktrees - Work with pull requests
- Clean Worktrees - Batch cleanup