Skip to content

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.

When you create a worktree, SCC places it in a sibling directory:

Git Worktree Structure
Git Worktree Structure

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 .gitignore if needed (though it’s already outside)
Terminal window
# Working on feature, need to fix urgent bug
git stash
git checkout main
git checkout -b bugfix-urgent
# Fix bug...
git checkout feature-branch
git stash pop
# Hope you didn't lose anything!
Terminal window
scc worktree create ~/project feature-auth

This creates:

  • Directory: ~/project-worktrees/feature-auth/ (outside the repository)
  • Branch: scc/feature-auth
Terminal window
scc worktree create ~/project feature-auth --branch existing-branch
Terminal window
scc worktree create ~/project feature-auth --launch

Creates the worktree and immediately starts SCC in it.

Terminal window
scc worktree enter feature-auth

This opens a subshell in the worktree directory. Type exit to return.

Add this to your ~/.bashrc or ~/.zshrc:

Terminal window
wt() {
local p
p="$(scc worktree switch "$@")" || return $?
cd "$p" || return 1
}

Then use:

Terminal window
wt feature-auth # cd to worktree
wt ^ # cd to main branch
wt - # cd to previous worktree
Terminal window
scc worktree list
Terminal window
scc worktree list -v

Output:

~/project-worktrees/feature-auth [scc/feature-auth]
+2 !1 ?3
~/project-worktrees/bugfix-login [scc/bugfix-login]
.
SymbolMeaning
+NN staged files
!NN modified files
?NN untracked files
.Clean worktree
Status timed out
Terminal window
scc worktree select
Terminal window
scc worktree switch feature-auth
Terminal window
scc worktree enter ^ # Main branch
scc worktree enter - # Previous worktree
Terminal window
scc worktree switch auth # Matches feature-auth
scc worktree switch scc/feature-x # Match by full branch name
Terminal window
scc worktree remove feature-auth
Terminal window
# Preview what would be removed
scc worktree prune -n
# Actually prune
scc worktree prune
  1. Create worktree for the feature

    Terminal window
    scc worktree create ~/project feature-payments
  2. Enter the worktree

    Terminal window
    scc worktree enter feature-payments
  3. Start SCC session

    Terminal window
    scc
  4. Work with Claude Code

    Claude makes changes in the isolated branch. Main stays clean.

  5. When done, exit and clean up

    Terminal window
    exit # Leave worktree subshell
    # If feature is complete and merged:
    scc worktree remove feature-payments
Terminal window
# Terminal 1: Working on payments
scc worktree enter feature-payments
scc
# Terminal 2: Working on auth
scc worktree enter feature-auth
scc
# Terminal 3: Quick bugfix
scc worktree enter bugfix-urgent
scc

Each terminal has its own Claude session in its own isolated branch.

SCC prefixes worktree branches with scc/:

Worktree NameBranch Created
feature-authscc/feature-auth
bugfix-loginscc/bugfix-login

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

A worktree with that name exists. Either:

  • Use a different name
  • Remove the existing worktree: scc worktree remove feature-auth

The repository needs at least one commit:

Terminal window
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:

Terminal window
scc worktree prune