Skip to content

status

The status command displays information about your current pgbranch state.

Terminal window
pgbranch status
Database: myapp_dev (localhost:5432)
Current branch: feature-auth
Total branches: 5
FieldDescription
DatabaseThe working database name and connection
Current branchThe currently active branch
Total branchesNumber of branches in the repository
Terminal window
pgbranch status

Output when on a branch:

Database: myapp_dev (localhost:5432)
Current branch: main
Total branches: 3

If you deleted the current branch or just initialized:

Database: myapp_dev (localhost:5432)
Current branch: (none)
Total branches: 0

Check your current state before performing operations:

Terminal window
# Before creating a branch
pgbranch status
# Output: Current branch: main
pgbranch branch new-feature

Use in scripts to verify pgbranch state:

#!/bin/bash
if pgbranch status | grep -q "Current branch: main"; then
echo "On main branch, proceeding..."
npm run migrate
else
echo "Please switch to main branch first"
exit 1
fi

If status fails, it helps diagnose connection problems:

Terminal window
pgbranch status

Possible errors:

Error: could not connect to database: connection refused
Error: pgbranch not initialized in this directory

For more detailed branch information, use log:

Terminal window
pgbranch log

For a simple list of branches:

Terminal window
pgbranch branch
  • log - Detailed branch history
  • branch - List all branches
  • checkout - Switch branches