This skill should be used when creating stacks, dependent branches, or when "stack", "stacked branches", "anchor", "--anchor", "but branch new -a", "create dependent branch", or "break feature into...
Dependent branches → anchor-based stacking → reviewable chunks.
NOT for: independent parallel features (use virtual branches), projects using Graphite stacking
| Type | Use Case | Dependencies |
|---|---|---|
| Virtual | Independent, unrelated work | None — parallel |
| Stacked | Sequential dependencies | Each builds on parent |
Stacked branches = virtual branches split into dependent sequence. Default: Virtual branches are stacks of one.
# Base branch (no anchor)
but branch new base-feature
# Stacked branch (--anchor specifies parent)
but branch new child-feature --anchor base-feature
# Third level
but branch new grandchild-feature --anchor child-feature
Result: base-feature ← child-feature ← grandchild-feature
Short form: -a instead of --anchor
but branch new child -a parent
Common patterns: feature dependency chains, refactoring sequences, deep stacks.
Example - Feature Dependency:
but branch new auth-core
but branch new auth-oauth --anchor auth-core
but branch new auth-social --anchor auth-oauth
See references/patterns.md for detailed patterns with commit examples.
Convert independent branches into a stack by recreating with correct anchors:
--anchor pointing to intended parentbut rub <sha> <new-branch>See references/reorganization.md for detailed workflows.
# Push and create PR for a branch
but push dependent-feature
but pr new dependent-feature
# Push all unpushed branches
but push
but push + but pr new handles:
# Push branches
git push -u origin base-feature
git push -u origin dependent-feature
# Create PRs with correct base branches
gh pr create --base main --head base-feature \
--title "feat: base feature" \
--body "First in stack"
gh pr create --base base-feature --head dependent-feature \
--title "feat: dependent feature" \
--body "Depends on base-feature PR"
GitButler resolves conflicts per-commit during rebase:
# Update base (may trigger rebases in stack)
but pull
# Check which commits have conflicts
but status
# Resolve in editor, GitButler auto-detects resolution
Unlike git rebase: Remaining commits continue rebasing even if some conflict.
Key operations for restructuring stacks:
| Operation | Command |
|---|---|
| Squash commits | but squash <branch> or but rub <newer> <older> |
| Move commit | but rub <sha> <target-branch> |
| Split branch | Create anchored branch, move commits |
See references/reorganization.md for detailed examples.
Note: Virtual branches don't need checkout — all branches active simultaneously.
# View full stack structure
but status
# Work on any branch directly (no checkout needed)
but commit base-feature -m "update base"
but commit dependent-feature -m "update dependent"
# Inspect a specific branch
but show dependent-feature
# JSON for programmatic analysis
but show dependent-feature --json | jq '.commits[] | .id'
ALWAYS:
--anchor from the startbut oplog snapshot --message "Before stack reorganization"NEVER:
| Symptom | Cause | Solution |
|---|---|---|
Stack not showing in but status |
Missing --anchor |
Recreate with correct anchor |
| Commits in wrong stack level | Wrong branch targeted | but rub <sha> correct-branch |
| Can't merge middle of stack | Wrong order | Merge bottom-to-top only |
To fix a branch with wrong/missing anchor: create new branch with correct anchor, move commits with but rub, delete original.
See references/reorganization.md for complete recovery procedures.
but status regularly to verify structurebut status when coordinatingreferences/patterns.md — Detailed stack patterns (feature dependency, refactoring, deep stacks)references/reorganization.md — Post-hoc organization, squashing, moving commits, splitting