> ## Documentation Index
> Fetch the complete documentation index at: https://docs-relytone.data.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Branching

> Instantly create isolated environments for development, testing, and recovery.

RelytONE branching lets you instantly create a full copy of your database. Use branches to safely test changes, debug issues, or run analytics without affecting your live production data.

<img src="https://mintcdn.com/relytone/dSnkOFzsx2vBECyE/images/branch.png?fit=max&auto=format&n=dSnkOFzsx2vBECyE&q=85&s=ef7f290949448d24c2e5fb5b18f9666d" alt="Database Branching Diagram" width="1408" height="564" data-path="images/branch.png" />

## Why use branches?

* **Isolated:** Changes in a branch stay in that branch. Your production data is never touched.
* **Fast & Efficient:** Creating a branch takes seconds and costs nothing in storage until you make changes.
* **Zero Overhead:** Branching happens without slowing down your main database.

## Common Use Cases

### Safe Development & Testing

* **Preview Environments:** Give every pull request its own dedicated database.
* **Real Data Testing:** Test new features against a copy of production data to catch bugs early.
* **Schema Validation:** Try out risky schema changes on a disposable branch before applying them to `main`.

### Instant Recovery & Debugging

* **Forensics:** Create a branch from a past timestamp to investigate exactly what the database looked like when an error occurred.
* **Data Recovery:** If data is accidentally deleted, spin up a branch from the moment before the deletion to recover it.

### Analytics Isolation

* **Heavy Queries:** Run complex analytical queries on a separate branch so you don't slow down your transactional application.

## Branching vs. Read Replicas

While both branches and read replicas provide copies of your data, they serve different purposes:

| Feature        | Branch                                                   | Read Replica                               |
| :------------- | :------------------------------------------------------- | :----------------------------------------- |
| **Data State** | Static snapshot at creation time (diverges as you write) | Continuously synchronized with the primary |
| **Writes**     | **Read-Write** (Independent)                             | **Read-Only**                              |
| **Best For**   | Development, Testing, Recovery, Experiments              | Scaling read traffic, High Availability    |
| **Impact**     | Isolated from primary                                    | Linked to primary (replication lag)        |

## How it Works

Every RelytONE project starts with a primary `main` branch. You can create new branches from `main` or any other existing branch.

Each branch functions as an independent database with its own connection string. You can connect to it using standard PostgreSQL tools. When you are finished with a task, simply delete the branch to keep your environment clean.
