What Are Git Worktrees?
Git worktrees allow you to have multiple working directories attached to a single repository. Instead of switching branches in place (which requires stashing or committing work-in-progress), each branch lives in its own directory.How Repo Manager Uses Worktrees
Repo Manager takes a worktree-first approach by combining:- Bare repositories - The git metadata lives in a
.bare/directory - Multiple worktrees - Each branch becomes a subdirectory
repo get, the structure looks like:
Benefits Over Standard Git Workflow
No Stashing Required
With standard git checkout:Parallel Work
Run builds, tests, or servers in multiple branches simultaneously:Instant Context Switching
No checkout delays, no modified file tracking - justcd between directories:
Common Workflows
Starting New Work
Reviewing Pull Requests
repo wt clean to remove all worktrees except the default branch:
Working on Multiple Features
Converting Existing Repositories
Migrate standard clones to worktree layout:- Moves
.git/to.bare/ - Creates
.gitfile pointing to.bare - Moves all files into a branch-named subdirectory
- Registers the worktree with git
Navigation Shortcuts
Repo Manager provides navigation commands for quick access:fzf is installed, you’ll get an interactive picker. Otherwise, it navigates to the default branch worktree.
See functions/goto.zsh:18-51 for picker implementation.
Technical Details
Bare Repository Configuration
When cloning, Repo Manager:- Creates a bare clone in
.bare/(functions/clone.zsh:34) - Configures fetch refspec:
+refs/heads/*:refs/remotes/origin/*(functions/clone.zsh:42) - Creates initial worktree for default branch (functions/clone.zsh:47)
- Sets upstream tracking automatically (functions/clone.zsh:52)
Worktree Creation
When adding a worktree withrepo wt add <branch>:
- Fetches latest from origin (functions/worktree.zsh:39)
- Checks if branch exists remotely or locally (functions/worktree.zsh:41-46)
- Creates new branch from default if not found (functions/worktree.zsh:49)
- Sets upstream tracking (functions/worktree.zsh:43)
Repository Root Resolution
Repo Manager finds the repository root by walking up directories looking for.bare/ (functions/core.zsh:16-27). This allows commands to work from any subdirectory within a worktree.