Skip to content

log

The log command displays detailed information about all branches, including creation time and parent relationships.

Terminal window
pgbranch log
* main (current)
Created: 2024-01-15 10:30:00
Parent: -
Snapshot: pgbranch_main_abc123
feature-auth
Created: 2024-01-15 14:22:00
Parent: main
Snapshot: pgbranch_feature_auth_abc123
feature-payments
Created: 2024-01-16 09:15:00
Parent: feature-auth
Snapshot: pgbranch_feature_payments_abc123
FieldDescription
Branch nameName of the branch, with * indicating current
CreatedTimestamp when the branch was created
ParentThe branch that was active when this branch was created
SnapshotThe PostgreSQL template database name

The parent branch shows the lineage of your branches:

main
└─▶ feature-auth (parent: main)
└─▶ feature-payments (parent: feature-auth)

This helps you understand:

  • Which branch a feature was based on
  • The evolution of your database schema
  • Where to look for baseline state
Terminal window
pgbranch log

When no branches exist:

No branches yet.

Before pruning old branches:

Terminal window
pgbranch log
# Review which branches exist and when they were created
pgbranch prune -d 30

When joining a project or returning after time away:

Terminal window
pgbranch log

See what database states exist and their relationships.

If you’re not sure which branch has the schema you need:

Terminal window
pgbranch log
# Find the branch created at the right time
pgbranch checkout pre-refactor
Terminal window
# Get branch names from log, then check sizes
for branch in $(pgbranch branch); do
size=$(psql -t -c "SELECT pg_size_pretty(pg_database_size('pgbranch_${branch}_*'))" 2>/dev/null)
echo "$branch: $size"
done
Terminal window
pgbranch log > branches-backup.txt

The log output uses color formatting in terminals:

  • Green: Current branch name
  • Yellow: Parent branch name
  • Dim: Timestamps and snapshot names

When piped or redirected, colors are automatically disabled.

  • branch - Simple branch list
  • status - Current state overview
  • diff - Compare schemas between branches