Git Worktrees
Git worktrees let you check out multiple branches simultaneously in different directories. SCC uses worktrees to isolate AI experiments and enable parallel development.
Worktree Location (CRITICAL)
Section titled “Worktree Location (CRITICAL)”When you create a worktree, SCC places it in a sibling directory:
Pattern: <repo-parent>/<repo-name>-worktrees/<feature-name>/
Example:
- Main repo:
/Users/dev/myproject/ - Worktrees:
/Users/dev/myproject-worktrees/feature-auth/ - NOT:
/Users/dev/myproject/.worktrees/feature-auth/❌
This external placement ensures:
- Main repository stays clean (no
.worktrees/directory) - No confusion with project files
- Easy to
.gitignoreif needed (though it’s already outside)
Why Use Worktrees?
Section titled “Why Use Worktrees?”# Working on feature, need to fix urgent buggit stashgit checkout maingit checkout -b bugfix-urgent# Fix bug...git checkout feature-branchgit stash pop# Hope you didn't lose anything!# Working on feature, need to fix urgent bugscc worktree create ~/project bugfix-urgentscc worktree enter bugfix-urgent# Fix bug in separate directory# Feature work untouched!Creating Worktrees
Section titled “Creating Worktrees”Basic Creation
Section titled “Basic Creation”scc worktree create ~/project feature-authThis creates:
- Directory:
~/project-worktrees/feature-auth/(outside the repository) - Branch:
scc/feature-auth
From Existing Branch
Section titled “From Existing Branch”scc worktree create ~/project feature-auth --branch existing-branchWith Immediate Launch
Section titled “With Immediate Launch”scc worktree create ~/project feature-auth --launchCreates the worktree and immediately starts SCC in it.
Entering Worktrees
Section titled “Entering Worktrees”Primary Method (Subshell)
Section titled “Primary Method (Subshell)”scc worktree enter feature-authThis opens a subshell in the worktree directory. Type exit to return.
Power User Method (Shell Wrapper)
Section titled “Power User Method (Shell Wrapper)”Add this to your ~/.bashrc or ~/.zshrc:
wt() { local p p="$(scc worktree switch "$@")" || return $? cd "$p" || return 1}Then use:
wt feature-auth # cd to worktreewt ^ # cd to main branchwt - # cd to previous worktreeListing Worktrees
Section titled “Listing Worktrees”Basic List
Section titled “Basic List”scc worktree listWith Git Status
Section titled “With Git Status”scc worktree list -vOutput:
~/project-worktrees/feature-auth [scc/feature-auth] +2 !1 ?3
~/project-worktrees/bugfix-login [scc/bugfix-login] .Status Indicators
Section titled “Status Indicators”| Symbol | Meaning |
|---|---|
+N | N staged files |
!N | N modified files |
?N | N untracked files |
. | Clean worktree |
… | Status timed out |
Switching Worktrees
Section titled “Switching Worktrees”Interactive Picker
Section titled “Interactive Picker”scc worktree selectDirect Switch
Section titled “Direct Switch”scc worktree switch feature-authQuick Navigation
Section titled “Quick Navigation”scc worktree enter ^ # Main branchscc worktree enter - # Previous worktreeFuzzy Matching
Section titled “Fuzzy Matching”scc worktree switch auth # Matches feature-authscc worktree switch scc/feature-x # Match by full branch nameRemoving Worktrees
Section titled “Removing Worktrees”Remove Specific Worktree
Section titled “Remove Specific Worktree”scc worktree remove feature-authPrune All Stale Worktrees
Section titled “Prune All Stale Worktrees”# Preview what would be removedscc worktree prune -n
# Actually prunescc worktree pruneWorktree + SCC Workflow
Section titled “Worktree + SCC Workflow”Typical Feature Development
Section titled “Typical Feature Development”-
Create worktree for the feature
Terminal window scc worktree create ~/project feature-payments -
Enter the worktree
Terminal window scc worktree enter feature-payments -
Start SCC session
Terminal window scc -
Work with Claude Code
Claude makes changes in the isolated branch. Main stays clean.
-
When done, exit and clean up
Terminal window exit # Leave worktree subshell# If feature is complete and merged:scc worktree remove feature-payments
Multiple Features in Parallel
Section titled “Multiple Features in Parallel”# Terminal 1: Working on paymentsscc worktree enter feature-paymentsscc
# Terminal 2: Working on authscc worktree enter feature-authscc
# Terminal 3: Quick bugfixscc worktree enter bugfix-urgentsccEach terminal has its own Claude session in its own isolated branch.
Branch Naming
Section titled “Branch Naming”SCC prefixes worktree branches with scc/:
| Worktree Name | Branch Created |
|---|---|
feature-auth | scc/feature-auth |
bugfix-login | scc/bugfix-login |
Advanced: Worktree Architecture
Section titled “Advanced: Worktree Architecture”Worktrees share the same .git repository as your main branch but have separate working directories. This allows:
- Multiple branches checked out simultaneously
- Shared Git history and configuration
- Independent file states per worktree
- No branch switching in your main repository
Troubleshooting
Section titled “Troubleshooting””Worktree already exists”
Section titled “”Worktree already exists””A worktree with that name exists. Either:
- Use a different name
- Remove the existing worktree:
scc worktree remove feature-auth
”Cannot create worktree: no commits”
Section titled “”Cannot create worktree: no commits””The repository needs at least one commit:
git commit --allow-empty -m "Initial commit"Worktree shows in list but directory missing
Section titled “Worktree shows in list but directory missing”The worktree was deleted externally. Prune it:
scc worktree prune