Push & Pull
Once you have a remote configured, you can push and pull branches to share with your team or sync across machines.
Push Command
Section titled “Push Command”Upload a local branch to remote storage.
pgbranch push <branch> [flags]| Flag | Short | Description | Default |
|---|---|---|---|
--remote | -r | Specify remote name | default remote |
--force | -f | Overwrite if exists on remote | false |
--description | -d | Add a description | - |
Examples
Section titled “Examples”Basic Push
Section titled “Basic Push”pgbranch push mainOutput:
Archiving branch 'main'...Archive size: 45 MBUploading to origin...Upload complete!Push to Specific Remote
Section titled “Push to Specific Remote”pgbranch push main --remote backupPush with Description
Section titled “Push with Description”pgbranch push main --description "Schema v2.1 with user auth"The description is shown when listing remote branches.
Force Overwrite
Section titled “Force Overwrite”pgbranch push main --forceWithout --force, pushing an existing branch fails:
Error: branch 'main' already exists on remote 'origin'Use --force to overwritePull Command
Section titled “Pull Command”Download a branch from remote storage.
pgbranch pull <branch> [flags]| Flag | Short | Description | Default |
|---|---|---|---|
--remote | -r | Specify remote name | default remote |
--as | - | Use different local name | same as remote |
--force | -f | Overwrite local branch | false |
Examples
Section titled “Examples”Basic Pull
Section titled “Basic Pull”pgbranch pull mainOutput:
Downloading 'main' from origin...Download complete (45 MB)Extracting archive...Branch 'main' createdPull to Different Name
Section titled “Pull to Different Name”pgbranch pull main --as main-from-remoteUseful when you want to keep your local main and compare with remote.
Pull from Specific Remote
Section titled “Pull from Specific Remote”pgbranch pull seed-data --remote teamForce Overwrite Local
Section titled “Force Overwrite Local”pgbranch pull main --forceWithout --force, pulling an existing local branch fails:
Error: local branch 'main' already existsUse --force to overwrite or --as to use a different nameRemote Branch Management
Section titled “Remote Branch Management”List Remote Branches
Section titled “List Remote Branches”pgbranch remote ls-remoteOutput:
main Pushed: 2024-01-15 10:30:00 Size: 45 MB Description: Schema v2.1 with user auth
feature-auth Pushed: 2024-01-16 14:22:00 Size: 48 MB
seed-data Pushed: 2024-01-14 09:00:00 Size: 52 MB Description: Full test datasetDelete from Remote
Section titled “Delete from Remote”pgbranch remote delete <branch> [--remote <name>]Example:
pgbranch remote delete old-feature --remote originThis only deletes the remote copy; local branches are unaffected.
Workflow Examples
Section titled “Workflow Examples”Team Onboarding
Section titled “Team Onboarding”New developer setup:
# Clone the projectgit clone https://github.com/team/project.gitcd project
# Initialize pgbranchpgbranch init -d project_dev
# Pull the seed data branchpgbranch pull seed-data
# Switch to itpgbranch checkout seed-data
# Ready to work!Sharing Feature Work
Section titled “Sharing Feature Work”Share your database state for code review:
# Push your feature branchpgbranch push feature-new-api --description "New API schema for review"
# Teammate pulls itpgbranch pull feature-new-api --as review-new-apipgbranch checkout review-new-api
# They can now test with your exact database stateMulti-Machine Sync
Section titled “Multi-Machine Sync”Working across machines:
# End of day at workpgbranch push wip-feature --force
# At homepgbranch pull wip-feature --forcepgbranch checkout wip-feature
# Continue working...
# End of day at homepgbranch push wip-feature --forceBackup Important States
Section titled “Backup Important States”Before risky operations:
# Save to remote before major changepgbranch push pre-migration --description "Before v3 migration"
# Run migrationnpm run migrate
# If it fails badly, you can always recoverpgbranch pull pre-migration --forcepgbranch checkout pre-migrationTransfer Rates
Section titled “Transfer Rates”Push and pull speed depends on:
- Database size
- Network bandwidth
- Storage backend latency
Typical times:
| Database Size | Compressed | Upload Time* |
|---|---|---|
| 100 MB | ~30 MB | ~5 seconds |
| 1 GB | ~300 MB | ~30 seconds |
| 10 GB | ~3 GB | ~5 minutes |
*Assumes 100 Mbps upload speed
Optimizing Transfer
Section titled “Optimizing Transfer”- Prune before push: Remove unnecessary data
- Use regional storage: Pick S3/R2 region close to you
- Use filesystem remote: For LAN, much faster than cloud
Error Handling
Section titled “Error Handling”Network Errors
Section titled “Network Errors”Error: upload failed: connection timeout- Check network connectivity
- Retry the command
- For large databases, use a stable connection
Storage Quota
Section titled “Storage Quota”Error: upload failed: storage quota exceeded- Delete old remote branches
- Increase storage quota
- Use lifecycle policies for auto-cleanup
Corrupt Archive
Section titled “Corrupt Archive”Error: archive verification failed- Re-push the branch
- If pulling, ask the pusher to re-upload
Best Practices
Section titled “Best Practices”Naming Conventions
Section titled “Naming Conventions”Use consistent branch names across the team:
main # Production-like schemaseed-data # Standard test datasetfeature-* # Feature brancheshotfix-* # Hotfix branchesDescriptions
Section titled “Descriptions”Always add descriptions for shared branches:
pgbranch push main --description "v2.1 schema with auth tables"Regular Cleanup
Section titled “Regular Cleanup”Periodically clean up remote branches:
# List remote branchespgbranch remote ls-remote
# Delete old onespgbranch remote delete feature-oldpgbranch remote delete feature-completedSeparate Remotes for Different Uses
Section titled “Separate Remotes for Different Uses”# Team collaborationpgbranch remote add team s3://team-bucket/pgbranch
# Personal backup (faster, cheaper)pgbranch remote add backup /mnt/backup/pgbranch
# Archive (infrequent access)pgbranch remote add archive s3://archive-bucket/pgbranchRelated Commands
Section titled “Related Commands”remote add- Configure remotesbranch- Manage local branchescheckout- Switch branches