Skip to content

Installation

Before installing pgbranch, ensure you have:

  • PostgreSQL - Any recent version (9.6+)
  • Go 1.21+ - Required for installation via go install

The easiest way to install pgbranch is using Go’s built-in package manager:

Terminal window
go install github.com/le-vlad/pgbranch/cmd/pgbranch@latest

This will download, compile, and install pgbranch to your $GOPATH/bin directory.

If you prefer to build from source:

Terminal window
# Clone the repository
git clone https://github.com/le-vlad/pgbranch.git
cd pgbranch
# Build the binary
go build -o pgbranch ./cmd/pgbranch
# Move to a directory in your PATH
mv pgbranch /usr/local/bin/

After installation, verify pgbranch is working:

Terminal window
pgbranch --help

You should see output showing the available commands and options.

To update pgbranch to the latest version:

Terminal window
go install github.com/le-vlad/pgbranch/cmd/pgbranch@latest

You can also check for updates using:

Terminal window
pgbranch update

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 snapshots
  • DROP DATABASE - To drop databases when switching branches

For local development, the default postgres superuser typically has all necessary permissions.

pgbranch supports standard PostgreSQL connection methods:

  1. Password authentication - Provide password via -W flag or when prompted
  2. Peer authentication - Uses your system username (common on Linux)
  3. Trust authentication - No password required (common in local development)

Once installed, proceed to the Quickstart guide to set up your first project.