log
The log command displays detailed information about all branches, including creation time and parent relationships.
pgbranch logOutput
Section titled “Output”* 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_abc123Output Fields
Section titled “Output Fields”| Field | Description |
|---|---|
| Branch name | Name of the branch, with * indicating current |
| Created | Timestamp when the branch was created |
| Parent | The branch that was active when this branch was created |
| Snapshot | The PostgreSQL template database name |
Understanding Parent Branches
Section titled “Understanding Parent Branches”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
Examples
Section titled “Examples”View All Branches
Section titled “View All Branches”pgbranch logNo Branches Yet
Section titled “No Branches Yet”When no branches exist:
No branches yet.Use Cases
Section titled “Use Cases”Review Before Cleanup
Section titled “Review Before Cleanup”Before pruning old branches:
pgbranch log# Review which branches exist and when they were createdpgbranch prune -d 30Understand Branch History
Section titled “Understand Branch History”When joining a project or returning after time away:
pgbranch logSee what database states exist and their relationships.
Debug Schema Issues
Section titled “Debug Schema Issues”If you’re not sure which branch has the schema you need:
pgbranch log# Find the branch created at the right timepgbranch checkout pre-refactorCombining with Other Commands
Section titled “Combining with Other Commands”Check Size of Each Branch
Section titled “Check Size of Each Branch”# Get branch names from log, then check sizesfor branch in $(pgbranch branch); do size=$(psql -t -c "SELECT pg_size_pretty(pg_database_size('pgbranch_${branch}_*'))" 2>/dev/null) echo "$branch: $size"doneExport Branch List
Section titled “Export Branch List”pgbranch log > branches-backup.txtOutput Formatting
Section titled “Output Formatting”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.