Git Workflows
Git patterns and worktree strategies for Sequant development.
Worktree Basics
Section titled “Worktree Basics”Creating Feature Worktrees
Section titled “Creating Feature Worktrees”Standard pattern for new feature work:
# Create worktree with new branchgit worktree add ../worktrees/feature/<N>-<slug> -b feature/<N>-<slug>
# Or use the helper script./scripts/dev/new-feature.sh <N>Worktree Locations
Section titled “Worktree Locations”By convention, worktrees live in a sibling directory:
~/Projects/├── sequant/ # Main repo└── worktrees/ └── feature/ ├── 10-windows-docs/ ├── 29-phase-detection/ └── ...This keeps worktrees separate from the main repo while allowing easy access.
Merging PRs with Active Worktrees
Section titled “Merging PRs with Active Worktrees”Worktrees lock their branches - you can’t delete a branch that’s checked out in a worktree.
Option A: Remove worktrees first (recommended)
Section titled “Option A: Remove worktrees first (recommended)”# 1. Remove the worktreegit worktree remove /path/to/worktree
# 2. Merge with branch cleanupgh pr merge <N> --squash --delete-branchOption B: Merge first, clean up after
Section titled “Option B: Merge first, clean up after”# 1. Merge WITHOUT --delete-branchgh pr merge <N> --squash
# 2. Remove the worktreegit worktree remove /path/to/worktree
# 3. Delete local branch manuallygit branch -D feature/<N>-*Batch cleanup
Section titled “Batch cleanup”After merging multiple PRs with worktrees:
# List all worktreesgit worktree list
# Remove merged worktreesgit worktree remove /path/to/worktree1git worktree remove /path/to/worktree2
# Clean up stale branchesgit fetch --prunegit branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -DFeature Branch Workflows
Section titled “Feature Branch Workflows”Use feature integration branches instead of branching directly from main.
When to Use Custom Base Branches
Section titled “When to Use Custom Base Branches”Use the --base flag when:
- Feature integration branches: Working on multiple related issues that should integrate before merging to main
- Release branches: Preparing a release with multiple fixes/features
- Team branches: In monorepos where teams have dedicated integration branches
- Epic development: Building a large feature across multiple issues
One-off Override (CLI Flag)
Section titled “One-off Override (CLI Flag)”# Branch issue #117 from feature/dashboard instead of mainnpx sequant run 117 --base feature/dashboard
# Multiple issues from the same basenpx sequant run 117 118 119 --base feature/dashboard
# Chain mode with custom basenpx sequant run 117 118 119 --sequential --chain --base feature/dashboardProject Configuration (Persistent)
Section titled “Project Configuration (Persistent)”Set a default base branch for all sequant run commands:
{ "run": { "defaultBase": "feature/dashboard" }}Now all runs use feature/dashboard as base:
npx sequant run 117 # Branches from feature/dashboardOverride with CLI flag when needed:
npx sequant run 120 --base main # Override back to mainResolution Priority
Section titled “Resolution Priority”Base branch is resolved in this order (highest priority first):
- CLI flag:
--base <branch> - Project config:
.sequant/settings.json→run.defaultBase - Default:
main
Visual Comparison
Section titled “Visual Comparison”Standard Workflow (no —base)
origin/main ├── feature/117-add-login ├── feature/118-add-logout └── feature/119-add-profileAll issues branch independently from main.
Feature Branch Workflow (—base)
origin/main └── feature/dashboard ← integration branch ├── feature/117-add-login ├── feature/118-add-logout └── feature/119-add-profileAll issues branch from the integration branch.
Chain Mode with —base
origin/main └── feature/dashboard └── feature/117-add-login └── feature/118-add-logout └── feature/119-add-profileEach issue builds on the previous, starting from the integration branch.
Chain Mode with —qa-gate
Section titled “Chain Mode with —qa-gate”For critical chains where you want to ensure each issue passes QA before the next begins:
npx sequant run 117 118 119 --sequential --chain --qa-gate --base feature/dashboardThis prevents downstream issues from building on potentially broken code.
Example: Dashboard Feature Development
Section titled “Example: Dashboard Feature Development”You have a feature/dashboard integration branch and 5 related issues:
# Option 1: Run independently (parallel)npx sequant run 117 118 119 120 121 --base feature/dashboard
# Option 2: Run as a chain (sequential dependencies)npx sequant run 117 118 119 120 121 --sequential --chain --base feature/dashboard
# Option 3: Set config and run without flagecho '{"run": {"defaultBase": "feature/dashboard"}}' > .sequant/settings.jsonnpx sequant run 117 118 119 120 121Script Usage
Section titled “Script Usage”The new-feature.sh script also supports --base:
# Create worktree from feature branch./scripts/dev/new-feature.sh 117 --base feature/dashboard
# With stash./scripts/dev/new-feature.sh 117 --base feature/dashboard --stashBest Practices
Section titled “Best Practices”- Keep integration branches fresh: Regularly merge main into your integration branch
- Use chain mode for dependencies: When issues must be implemented in order
- Limit chain length: Recommended max 5 issues per chain
- Config for team branches: Use
settings.jsonwhen team consistently uses same base - Override for exceptions: Use
--base mainwhen an issue should bypass the integration branch
Troubleshooting
Section titled “Troubleshooting””Branch does not exist” Error
Section titled “”Branch does not exist” Error”The base branch must exist on the remote:
# Check if branch existsgit branch -r | grep feature/dashboard
# If not, create and push it firstgit checkout -b feature/dashboardgit push -u origin feature/dashboardMerge Conflicts
Section titled “Merge Conflicts”When working on an integration branch, conflicts may arise:
- Update your integration branch:
git pull origin main(on integration branch) - Rebase feature branches if needed
- Re-run the failed issue
Config Not Working
Section titled “Config Not Working”Verify your settings file:
cat .sequant/settings.json | jq '.run.defaultBase'Ensure valid JSON syntax and correct field name (defaultBase, not baseBranch).