Skip to content

Push & Pull

Once you have a remote configured, you can push and pull branches to share with your team or sync across machines.

Upload a local branch to remote storage.

Terminal window
pgbranch push <branch> [flags]
FlagShortDescriptionDefault
--remote-rSpecify remote namedefault remote
--force-fOverwrite if exists on remotefalse
--description-dAdd a description-
Terminal window
pgbranch push main

Output:

Archiving branch 'main'...
Archive size: 45 MB
Uploading to origin...
Upload complete!
Terminal window
pgbranch push main --remote backup
Terminal window
pgbranch push main --description "Schema v2.1 with user auth"

The description is shown when listing remote branches.

Terminal window
pgbranch push main --force

Without --force, pushing an existing branch fails:

Error: branch 'main' already exists on remote 'origin'
Use --force to overwrite

Download a branch from remote storage.

Terminal window
pgbranch pull <branch> [flags]
FlagShortDescriptionDefault
--remote-rSpecify remote namedefault remote
--as-Use different local namesame as remote
--force-fOverwrite local branchfalse
Terminal window
pgbranch pull main

Output:

Downloading 'main' from origin...
Download complete (45 MB)
Extracting archive...
Branch 'main' created
Terminal window
pgbranch pull main --as main-from-remote

Useful when you want to keep your local main and compare with remote.

Terminal window
pgbranch pull seed-data --remote team
Terminal window
pgbranch pull main --force

Without --force, pulling an existing local branch fails:

Error: local branch 'main' already exists
Use --force to overwrite or --as to use a different name
Terminal window
pgbranch remote ls-remote

Output:

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 dataset
Terminal window
pgbranch remote delete <branch> [--remote <name>]

Example:

Terminal window
pgbranch remote delete old-feature --remote origin

This only deletes the remote copy; local branches are unaffected.

New developer setup:

Terminal window
# Clone the project
git clone https://github.com/team/project.git
cd project
# Initialize pgbranch
pgbranch init -d project_dev
# Pull the seed data branch
pgbranch pull seed-data
# Switch to it
pgbranch checkout seed-data
# Ready to work!

Share your database state for code review:

Terminal window
# Push your feature branch
pgbranch push feature-new-api --description "New API schema for review"
# Teammate pulls it
pgbranch pull feature-new-api --as review-new-api
pgbranch checkout review-new-api
# They can now test with your exact database state

Working across machines:

Terminal window
# End of day at work
pgbranch push wip-feature --force
# At home
pgbranch pull wip-feature --force
pgbranch checkout wip-feature
# Continue working...
# End of day at home
pgbranch push wip-feature --force

Before risky operations:

Terminal window
# Save to remote before major change
pgbranch push pre-migration --description "Before v3 migration"
# Run migration
npm run migrate
# If it fails badly, you can always recover
pgbranch pull pre-migration --force
pgbranch checkout pre-migration

Push and pull speed depends on:

  • Database size
  • Network bandwidth
  • Storage backend latency

Typical times:

Database SizeCompressedUpload Time*
100 MB~30 MB~5 seconds
1 GB~300 MB~30 seconds
10 GB~3 GB~5 minutes

*Assumes 100 Mbps upload speed

  1. Prune before push: Remove unnecessary data
  2. Use regional storage: Pick S3/R2 region close to you
  3. Use filesystem remote: For LAN, much faster than cloud
Error: upload failed: connection timeout
  • Check network connectivity
  • Retry the command
  • For large databases, use a stable connection
Error: upload failed: storage quota exceeded
  • Delete old remote branches
  • Increase storage quota
  • Use lifecycle policies for auto-cleanup
Error: archive verification failed
  • Re-push the branch
  • If pulling, ask the pusher to re-upload

Use consistent branch names across the team:

main # Production-like schema
seed-data # Standard test dataset
feature-* # Feature branches
hotfix-* # Hotfix branches

Always add descriptions for shared branches:

Terminal window
pgbranch push main --description "v2.1 schema with auth tables"

Periodically clean up remote branches:

Terminal window
# List remote branches
pgbranch remote ls-remote
# Delete old ones
pgbranch remote delete feature-old
pgbranch remote delete feature-completed
Terminal window
# Team collaboration
pgbranch 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/pgbranch