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

# Working with branches

> Find the branch you are on, create and switch branches, manage them in one place, change the default branch, and delete branches. This page also covers what happens to unsaved changes.

This page covers the day-to-day work with branches. It describes the Frontend. A Logic service works the same way, with the differences listed in [Branches in a Logic service](https://archie.com/docs/backend/logic/branches.md).

## The branch menu

The branch chip in the Frontend header shows the name of the branch you are on. A lock appears on the chip when the branch is protected. Select the chip to open the branch menu.

The menu has these parts:

* **Current branch**, with a badge. **Editable** means changes save to this branch. **Read only** means you cannot write to it, for example while you resolve the conflicts of a pull request. **Protected** means changes reach it only through a merge.
* **Backend**, with the environment the preview of this branch is connected to and a **Change** button. See [The environment of a branch](https://archie.com/docs/frontend/branching/previews-and-publishing.md#the-environment-of-a-branch).
* **Find a branch**, to filter the list. Each branch can be marked **default** and with a lock when it is protected. When the list is long, select **Show N more**.
* **New branch**, **Open pull request**, **Pull requests**, and **Manage branches** at the bottom. **Open pull request** is not available on a protected branch.

While a merge into a protected branch is finishing, the menu marks the branch as **landing**. Writes to that branch wait until it is ready.

## Create a branch

1. Open the branch menu and select **New branch**. You can also use **New branch** in **Manage branches**, or **New branch from *branch*** in the protected branch banner.
2. In **New branch from *branch***, type a **Name**.
3. Select **Create branch**.

The new branch starts as a copy of the source branch at its latest commit, and Archie moves you to it. The dialog also says that the branch uses the project's backend environment and that you can change it later.

If the source branch moved while the dialog was open, you see that it moved and can select **Create from *commit*** to start from the new head.

Branch names follow these rules:

* Use letters, numbers, `-`, `_`, `.`, and `/`.
* Names that start with `archie/` are reserved.
* A 40-character hexadecimal name is not accepted, because it looks like a commit.
* A branch with that name must not already exist.

### Branch limits

Your plan includes a number of extra branches per project. When you reach the limit, **Create branch** is blocked and the dialog reads "You reached your plan's branch limit. Delete one to keep creating." Delete a branch you no longer need, or add capacity from the notice. Nothing you already have is deleted or turned off when you reach a limit.

## Switch branches

Select a branch in the branch menu. The code editor, the preview, and the history show the branch you switched to.

### Unsaved changes

If you have edits that are not saved, Archie asks before it switches. The dialog counts your code changes and your visual editor changes and offers three options:

| Option | What happens |
| - | - |
| **Save to *branch* and switch** | Saves your edits to the branch you are leaving, then switches. |
| **Switch without saving (edits stay as a draft of *branch*)** | Switches and keeps your edits as a draft of the branch you left. |
| **Cancel** | Keeps you where you are. |

### When someone else changed the branch

If another person saved to the branch while you had it open, you see "This branch changed since you opened it." Your edits are kept until you decide:

* **Keep mine in a new branch** saves your work as its own branch.
* **Reload and re-apply my changes** loads the new version and puts your edits on top.

### When the branch no longer exists

If the branch you are on is deleted, Archie moves you to the default branch and shows "*branch* no longer exists. You're on *default*." If the default branch changes in another tab, you stay where you are and a notice offers **Go to *branch*** so you can follow it.

## Manage branches

**Manage branches** lists all the branches of the Frontend in one place. Open it from the branch menu. It opens as a panel on the right with three tabs: **Branches**, **Pull requests**, and **Settings**.

Above the tabs, **Default branch:** shows the current default. Owners and Admins also see **Change** next to it.

The **Branches** tab lists each branch with these columns:

| Column | What it shows |
| - | - |
| **Branch** | The name, a **default** mark, **you are here** for your current branch, and the environment its preview uses. |
| **Last commit** | The latest commit, with a button to **Copy commit SHA**. |
| **Protection** | **Protected**, and the rules that apply, such as **No rules**, an approvals count, or **requires a pull request**. A branch that is also protected on GitHub shows **Also protected on GitHub**. |
| **Author** | The author of the latest commit. |
| **Actions** | The row menu. |

The row menu offers the actions that apply to that branch and to your role:

* **Switch to**
* **Open pull request**
* **Merge directly into *branch***, for a protected branch without rules. See [Merging without a pull request](https://archie.com/docs/frontend/branching/pull-requests.md#merge-without-a-pull-request).
* **Protect branch**, **Unprotect branch**, and **Protection rules**
* **Delete branch**

Use **New branch** at the top of the panel to create a branch. Use the filter to find a branch by name.

If a branch has an open pull request or a merge that did not finish, its row says so. A row that reads **Merge incomplete** has a **Retry** button.

The **Settings** tab has two project-wide settings:

* **Who can publish**. See [Permissions](https://archie.com/docs/frontend/branching/permissions.md#who-can-publish-and-merge-into-protected-branches).
* **Code review**. See [Archie Reviewer](https://archie.com/docs/frontend/branching/archie-reviewer.md#when-archie-reviews).

## Change the default branch

Owners and Admins can make another branch the default.

1. In **Manage branches**, select **Change** next to **Default branch:**.
2. Select **Choose a branch** and pick the new default.
3. Confirm with **Make *branch* the default**.

Before you confirm, keep in mind:

* The change affects only that part. Changing the Frontend's default does not change the default of any service.
* **Nothing is published or deployed.** The public site stays on what it was until you publish.
* The old default keeps its history. Protection and rules stay with each branch by name, and open pull requests keep their target.
* If the old default was protected and the new one is not, the dialog tells you and you can protect the new one afterwards.
* The project preview restarts on the new default branch.
* If the project is connected to GitHub, the dialog also explains what changes on the GitHub side.

## Delete a branch

Select **Delete branch** in the row menu and confirm.

* **The default branch cannot be deleted.** Make another branch the default first.
* **A protected branch cannot be deleted.** Unprotect it first.
* Only the person who created a branch, or an Owner or Admin, can delete it.
* If you are on the branch, Archie moves you to the default branch. Unsaved edits are kept as a draft that you can review.
* The preview of the branch stops existing. What you already published stays available to publish again.
* If the branch has changes that have not reached the repository yet, the dialog warns you that deleting now loses them.

## Next steps

* Keep a branch safe with [Protected branches](https://archie.com/docs/frontend/branching/protected-branches.md).
* Bring your work back with [Pull requests](https://archie.com/docs/frontend/branching/pull-requests.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.