Installation
Requirements
Section titled “Requirements”Before installing pgbranch, ensure you have:
- PostgreSQL - Any recent version (9.6+)
- Go 1.21+ - Required for installation via
go install
Installation Methods
Section titled “Installation Methods”Using Go Install (Recommended)
Section titled “Using Go Install (Recommended)”The easiest way to install pgbranch is using Go’s built-in package manager:
go install github.com/le-vlad/pgbranch/cmd/pgbranch@latestThis will download, compile, and install pgbranch to your $GOPATH/bin directory.
Building from Source
Section titled “Building from Source”If you prefer to build from source:
# Clone the repositorygit clone https://github.com/le-vlad/pgbranch.gitcd pgbranch
# Build the binarygo build -o pgbranch ./cmd/pgbranch
# Move to a directory in your PATHmv pgbranch /usr/local/bin/Verifying Installation
Section titled “Verifying Installation”After installation, verify pgbranch is working:
pgbranch --helpYou should see output showing the available commands and options.
Updating
Section titled “Updating”To update pgbranch to the latest version:
go install github.com/le-vlad/pgbranch/cmd/pgbranch@latestYou can also check for updates using:
pgbranch updatePostgreSQL Configuration
Section titled “PostgreSQL Configuration”pgbranch requires access to create and manage databases in PostgreSQL. The PostgreSQL user you configure needs the following permissions:
CREATEDB- To create template databases for snapshotsDROP DATABASE- To drop databases when switching branches
For local development, the default postgres superuser typically has all necessary permissions.
Connection Methods
Section titled “Connection Methods”pgbranch supports standard PostgreSQL connection methods:
- Password authentication - Provide password via
-Wflag or when prompted - Peer authentication - Uses your system username (common on Linux)
- Trust authentication - No password required (common in local development)
Next Steps
Section titled “Next Steps”Once installed, proceed to the Quickstart guide to set up your first project.