Worktrees
Worktrees are gitβs built-in feature for having multiple working directories from a single repository. Bearing uses them to isolate work.
How They Work
A worktree is a separate working directory with its own checked-out branch, but sharing the same git history:
myapp/ # Base folder (main branch)
βββ .git/ # Main git directory
βββ src/
βββ package.json
myapp-feature-auth/ # Worktree (feature-auth branch)
βββ .git # File linking to main .git
βββ src/ # Separate working copy
βββ package.json
Benefits
- Full isolation - Each worktree has its own files
- No stashing - Keep changes in progress, switch tasks freely
- Parallel work - Multiple agents work simultaneously
- Shared history - All worktrees share commits, branches, remotes
Lifecycle
# Create worktree for a task
bearing worktree new myapp feature-auth
# Work in it
cd myapp-feature-auth
git add . && git commit -m "Add auth"
git push -u origin feature-auth
# Clean up after merge
bearing worktree cleanup myapp feature-auth
Git Commands (Under the Hood)
Bearing wraps these git commands:
# Creating a worktree
git -C myapp worktree add ../myapp-feature-auth -b feature-auth
# Listing worktrees
git -C myapp worktree list
# Removing a worktree
git -C myapp worktree remove ../myapp-feature-auth
git -C myapp worktree prune
You can use git directly if neededβBearing wonβt break.