Git worktrees are a powerful feature that allow you to have multiple branches checked out simultaneously in different directories. Amplifier extends this with additional features for managing parallel development workflows.
# Create a new worktree for experimentation
make worktree my-feature
# Navigate to the new worktree
cd ../amplifier.my-feature
# Work on your feature (already has .venv set up!)
# ...make changes, test, etc...
# When done, remove it
make worktree-rm my-feature- Parallel Experiments: Test multiple approaches simultaneously
- Clean Isolation: Each worktree has its own branch, files, and virtual environment
- Fast Switching: No stashing/unstashing or branch switching needed
- Risk-Free: Experiment freely without affecting your main work
# Basic usage
make worktree feature-name
# With namespaced branches (e.g., for teams)
make worktree username/feature-nameWhat happens:
- Creates directory:
../amplifier.feature-name/ - Creates/uses branch:
feature-name(orusername/feature-name) - Copies
.data/directory for knowledge base access - Sets up isolated Python virtual environment
- Ready to use immediately!
Amplifier uses a dot (.) separator between repo name and feature:
amplifier.feature-name- Clear separationamplifier.complex-feature-name- Handles hyphens in namesamplifier.feature-name(fromusername/feature-name) - Strips namespace from directory
# List all active worktrees
make worktree-list
# Remove a worktree and its branch
make worktree-rm feature-name
# Force remove (even with uncommitted changes)
make worktree-rm-force feature-nameSometimes you want to declutter your workspace without losing work. The stash feature hides worktrees from git worktree list and VSCode while preserving the directory and all files.
# Hide a worktree from git (keeps directory intact)
make worktree-stash feature-name
# List all hidden worktrees
make worktree-list-stashed
# Restore a hidden worktree
make worktree-unstash feature-nameUse cases:
- Too many worktrees cluttering VSCode's git view
- Temporarily pause work without losing state
- Clean up workspace for focused work
How it works:
- Removes git's tracking metadata only
- Directory and all files remain untouched
- Can be restored anytime with full history
Pull down branches created on other machines or by teammates:
# Create worktree from a remote branch
make worktree-adopt origin/feature-name
# Or if someone else created it
make worktree-adopt teammate/cool-featureWhat happens:
- Fetches latest from origin
- Creates local worktree tracking the remote branch
- Sets up directory as
amplifier.cool-feature - Ready to continue work started elsewhere
Perfect for:
- Continuing work started on another machine
- Checking out a colleague's branch for review
- Testing branches from CI/CD pipelines
# Feature development
make worktree feat-authentication
# Bug fixes
make worktree fix-login-error
# Experiments
make worktree exp-new-algorithm
# With namespaces
make worktree myname/feat-caching# Create multiple approaches
make worktree approach-redis
make worktree approach-memcached
make worktree approach-inmemory
# Test each in parallel
cd ../amplifier.approach-redis && make test
cd ../amplifier.approach-memcached && make test
cd ../amplifier.approach-inmemory && make test
# Keep the winner, remove the rest
make worktree-rm approach-memcached
make worktree-rm approach-inmemory# Working on multiple features
make worktree-list # Shows 8 worktrees - too many!
# Stash the ones not actively being worked on
make worktree-stash old-feature-1
make worktree-stash old-feature-2
make worktree-stash experimental-thing
make worktree-list # Now shows only 5 active ones
# Later, when ready to resume
make worktree-unstash experimental-thingMachine A (office):
make worktree my-feature
# ...work on feature...
cd ../amplifier.my-feature
git push -u origin my-featureMachine B (home):
make worktree-adopt my-feature
cd ../amplifier.my-feature
# ...continue work...Each worktree gets its own isolated Python environment automatically. See WORKTREE_VENV_MANAGEMENT.md for details.
Key points:
- Automatic
.venvcreation in each worktree - No conflicts between worktrees
- Dependencies isolated per experiment
make checkhandles environment switching automatically
| Command | Description | Example |
|---|---|---|
make worktree NAME |
Create new worktree | make worktree my-feature |
make worktree-list |
List active worktrees | make worktree-list |
make worktree-rm NAME |
Remove worktree and branch | make worktree-rm my-feature |
make worktree-rm-force NAME |
Force remove with changes | make worktree-rm-force my-feature |
make worktree-stash NAME |
Hide worktree (keep files) | make worktree-stash old-feature |
make worktree-unstash NAME |
Restore hidden worktree | make worktree-unstash old-feature |
make worktree-list-stashed |
List hidden worktrees | make worktree-list-stashed |
make worktree-adopt BRANCH |
Create from remote branch | make worktree-adopt origin/feature |
If you get this error, the branch might already have a worktree:
make worktree-list # Check existing worktrees
make worktree-rm old-one # Remove if neededIf normal remove fails:
# Force remove (loses uncommitted changes!)
make worktree-rm-force stubborn-feature
# Manual cleanup if completely broken
rm -rf ../amplifier.stubborn-feature
rm -rf .git/worktrees/amplifier.stubborn-feature
git branch -D stubborn-featureIf unstash fails:
# Check if directory still exists
ls ../amplifier.feature-name
# Check stash manifest
cat .git/worktree-stash.json
# If directory is gone, remove from stash
# Edit .git/worktree-stash.json to remove the entryVSCode might need a restart after creating worktrees:
- Create worktree
- Open the worktree directory in VSCode
- If git features aren't working, reload VSCode window (Ctrl+Shift+P → "Reload Window")
Add to your global gitignore to keep worktrees clean:
echo "amplifier-*/" >> ~/.gitignore_global
echo "amplifier.*/" >> ~/.gitignore_globalAdd aliases to your shell:
# In ~/.bashrc or ~/.zshrc
alias wt-main='cd ~/repos/amplifier'
alias wt-list='cd ~/repos/amplifier && make worktree-list'
alias wt-cd='cd ~/repos/amplifier..$1'# Remove all prunable worktrees at once
git worktree prune
# List and remove all stale worktrees
for wt in $(git worktree list --porcelain | grep "prunable" -B 2 | grep "worktree" | cut -d' ' -f2); do
rm -rf "$wt"
doneCreate a template for common worktree setups:
#!/bin/bash
# save as make-feature-worktree.sh
make worktree $1
cd ../amplifier.$1
echo "# $1 Feature" > NOTES.md
mkdir -p tests docs
echo "Ready to work on $1!"Each worktree can use all Amplifier agents:
cd ../amplifier.my-experiment
claude # Start Claude with all agents available
# "Use zen-architect to design this experiment"All worktrees share the same knowledge base (if using external AMPLIFIER_DATA_DIR):
# In any worktree
make knowledge-query Q="authentication patterns"
# Gets same results across all worktreesTest multiple approaches while preserving conversation history:
# In worktree 1
claude # Design approach A
# /compact when needed (auto-saves transcript)
# In worktree 2
claude # Design approach B
# /compact when needed (separate transcript)
# Later, compare transcripts
make transcript-search TERM="performance"Git worktrees in Amplifier provide a powerful way to:
- Experiment freely without fear of breaking your main work
- Test in parallel to find the best solution faster
- Manage complexity by hiding inactive work
- Collaborate easily by adopting branches from anywhere
The stash/unstash and adopt features extend git's native worktrees to handle real-world development workflows where you need to juggle multiple experiments, pause and resume work, and collaborate across machines.