> ## 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.

# Protected branches

> Protect a branch so nobody writes to it directly. Learn what protection blocks, how to keep working when a branch is protected, and how protection rules decide when a pull request can merge.

A **protected branch** is a branch where nobody writes directly. Use it to keep an important branch, usually the default one, from changing by accident while people and the chat work on other branches.

No branch is protected when it is created. You choose which branches to protect.

## What protection blocks

On a protected branch, changes reach the branch only through a merge. Direct writes are blocked everywhere:

* **The chat.** It stops before it writes and asks where to continue. See [The chat and branches](https://archie.com/docs/frontend/branching/chat-and-branches.md#protected-branches-the-chat-asks-where-to-continue).
* **The code editor.** In the Frontend, saving is refused. You see **Your changes were not saved**, your edits stay in the editor, and you can save them in a new branch or switch to another one. In a service, the code is read-only.
* **The visual editor and the theme editor.** They show "This branch is protected: create a branch to edit" and "This branch is protected: create a branch to edit the theme".
* **Applying a pull request suggestion** to a protected branch.

The branch chip shows a lock. A banner explains the state and offers **Switch branch** and **New branch**. The banner appears above the editor and in the chat box. Select **What can I do?** in the banner to see what you can and cannot do on that branch.

### What protection does not block

* **Reading, previewing, and sharing.** You can open the branch and its preview, switch to it, and create share links from it. Right after a merge into a protected branch, sharing waits until the branch finishes updating.
* **Creating branches from it.** This is the normal way to continue: create a branch and work there.
* **Publishing and deploying.** These are separate actions that take a branch and a commit. See [Previews, sharing, and publishing](https://archie.com/docs/frontend/branching/previews-and-publishing.md).

While a branch is protected, the environment its preview is connected to cannot change. The branch menu says "The environment can't change while this branch is protected."

## Make changes to a protected branch

1. **Create a branch** from the protected one. Select **New branch** in the banner or in the branch menu.
2. Make your changes on the new branch.
3. **Open a pull request** into the protected branch. If the protected branch has no rules, you can also merge directly. See [Pull requests](https://archie.com/docs/frontend/branching/pull-requests.md).

If you have unsaved edits when you create the branch from the banner, they go to the new branch.

From the chat, one click does the first two steps for you: **Create branch *name* and continue**.

## Protect and unprotect a branch

Only Owners and Admins can protect and unprotect branches. Open **Manage branches**, find the branch, and open the row menu.

* Select **Protect branch** and confirm with **Protect**. The dialog explains that changes reach the branch only through a merge and that visual edits and chat are blocked on it.
* Select **Unprotect branch** and confirm. The branch accepts direct changes again: visual edits, chat, and code saves.

**Unprotecting a branch removes its rules.** The confirmation lists the rules that will be removed. If you protect the branch again, you need to set the rules up again.

## Protection rules

Rules decide **when a pull request can merge** into a protected branch. Select **Protection rules** in the row menu of a protected branch. The dialog explains that nobody writes directly to a protected branch and that the rules decide when a pull request can merge.

| Rule | What it does |
| - | - |
| **Required approvals** | The number of people who must approve the pull request. The author's own approval does not count. You can require at most as many approvals as there are people besides the author who can approve. |
| **Require Archie Reviewer** | Archie must review the pull request before it can merge. Each review consumes credits. See [Archie Reviewer](https://archie.com/docs/frontend/branching/archie-reviewer.md). |

Rules also apply to pull requests that are already open into that branch.

**A branch with rules requires a pull request.** Its row says **requires a pull request**, and merging into it directly is not offered. You see "*branch* requires review: merge it from a pull request." A protected branch with **No rules** can be merged into directly. See [Merging without a pull request](https://archie.com/docs/frontend/branching/pull-requests.md#merge-without-a-pull-request).

## Next steps

* [Pull requests](https://archie.com/docs/frontend/branching/pull-requests.md)
* [Permissions](https://archie.com/docs/frontend/branching/permissions.md)


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