status
The status command displays information about your current pgbranch state.
pgbranch statusOutput
Section titled “Output”Database: myapp_dev (localhost:5432)Current branch: feature-authTotal branches: 5Output Fields
Section titled “Output Fields”| Field | Description |
|---|---|
| Database | The working database name and connection |
| Current branch | The currently active branch |
| Total branches | Number of branches in the repository |
Examples
Section titled “Examples”Basic Status Check
Section titled “Basic Status Check”pgbranch statusOutput when on a branch:
Database: myapp_dev (localhost:5432)Current branch: mainTotal branches: 3No Current Branch
Section titled “No Current Branch”If you deleted the current branch or just initialized:
Database: myapp_dev (localhost:5432)Current branch: (none)Total branches: 0Use Cases
Section titled “Use Cases”Verify Before Operations
Section titled “Verify Before Operations”Check your current state before performing operations:
# Before creating a branchpgbranch status# Output: Current branch: main
pgbranch branch new-featureScripting and Automation
Section titled “Scripting and Automation”Use in scripts to verify pgbranch state:
#!/bin/bashif pgbranch status | grep -q "Current branch: main"; then echo "On main branch, proceeding..." npm run migrateelse echo "Please switch to main branch first" exit 1fiDebugging Connection Issues
Section titled “Debugging Connection Issues”If status fails, it helps diagnose connection problems:
pgbranch statusPossible errors:
Error: could not connect to database: connection refusedError: pgbranch not initialized in this directoryRelated Information
Section titled “Related Information”For more detailed branch information, use log:
pgbranch logFor a simple list of branches:
pgbranch branch