Branch Commands¶
Manage schema branches for isolated development.
list¶
List all branches in the active database.
Example Output¶
Branches in database 'main':
• main (active)
• feature.add-users
• feature.update-schema
• hotfix.fix-indexes
create¶
Create a new branch from the current branch.
Arguments¶
BRANCH_NAME
- Name of the new branch
Options¶
--from BRANCH
- Source branch (defaults to current branch)
Examples¶
Notes¶
- Copies all schema and tenants from source branch
- Branch names can include periods and dashes for organization
- Cannot create duplicate branch names
switch¶
Switch to a different branch.
Arguments¶
BRANCH_NAME
- Branch to switch to
Example¶
Notes¶
- Updates
active_branch
in config - All subsequent commands use the new branch
- Does not affect any uncommitted data
delete¶
Delete a branch.
Arguments¶
BRANCH_NAME
- Branch to delete
Options¶
--force
- Skip confirmation
Example¶
# With confirmation
cinch branch delete feature.old-feature
# Without confirmation
cinch branch delete feature.old-feature --force
Notes¶
- Cannot delete the
main
branch - Cannot delete the active branch
- Permanently removes all branch data
merge¶
Merge changes from one branch into another.
Arguments¶
SOURCE_BRANCH
- Branch with changes to mergeTARGET_BRANCH
- Branch to merge into
Examples¶
# Merge feature into main
cinch branch merge feature.add-users main
# Merge while on target branch
cinch branch switch main
cinch branch merge feature.add-users .
Notes¶
- Target branch must have all changes from source
- Changes are applied to all tenants
- Cannot merge if there are conflicts
merge-into-main¶
Shortcut to merge current branch into main.
Example¶
# On feature branch
cinch branch switch feature.add-users
# Make changes...
cinch branch merge-into-main
Equivalent to:¶
changes¶
View changes made in a branch.
Arguments¶
BRANCH_NAME
- Branch to inspect (defaults to current)
Example Output¶
Changes in branch 'feature.add-users':
1. CREATE TABLE users (name TEXT, email TEXT)
2. CREATE VIEW active_users AS SELECT * FROM users WHERE active = true
3. ADD COLUMN avatar_url TEXT TO users
Common Workflows¶
Feature Development¶
# Create feature branch
cinch branch create feature.shopping-cart
# Make changes
cinch table create cart_items product_id:TEXT quantity:INTEGER
cinch table create orders user_id:TEXT total:REAL
# Review changes
cinch branch changes
# Merge to main
cinch branch merge-into-main
Hotfix Workflow¶
# Create hotfix from main
cinch branch create hotfix.fix-index --from main
# Make fix
cinch column add users last_login:TEXT
# Merge back quickly
cinch branch merge hotfix.fix-index main
Parallel Development¶
# Multiple features in parallel
cinch branch create feature.users
cinch branch create feature.products
cinch branch create feature.orders
# Work independently
cinch branch switch feature.users
cinch table create users name:TEXT
cinch branch switch feature.products
cinch table create products name:TEXT price:REAL
# Merge when ready
cinch branch merge feature.users main
cinch branch merge feature.products main
Best Practices¶
- Branch Naming - Use descriptive names like
feature.
,bugfix.
,hotfix.
- Small Changes - Keep branches focused on single features
- Regular Merges - Merge completed features promptly
- Review Changes - Always review before merging to main
- Clean Up - Delete merged branches to keep list manageable
Troubleshooting¶
"Branch already exists"¶
Problem: cinch branch create feature.users
fails with "Branch already exists"
Solution: Use cinch branch list
to check existing branches, choose a different name
"Cannot merge: conflicts detected"¶
Problem: Merge fails with schema conflicts
Solution:
1. Review changes: cinch branch changes feature.branch
2. Check target: cinch branch changes main
3. Resolve manually or recreate branch from updated main
"Cannot delete active branch"¶
Problem: Trying to delete the currently active branch
Solution: Switch first: cinch branch switch main
, then delete
Protection Rules¶
- The
main
branch cannot be deleted - Direct changes to
main
are not allowed (merge only) - All schema changes must go through branches
Remote Operations¶
Branch commands work with remote connections:
Next Steps¶
- Table Commands - Create tables in branches
- Column Commands - Modify schemas in branches
- Schema Branching Concepts - Deep dive into branching theory
- Change Tracking - How changes are tracked
- Schema Branching Tutorial - End-to-end workflow example