# Branches

> Which branch your site publishes from, how to change it, and how to use feature branches, pull requests and previews for review.

Your site publishes from one branch of your repository, the deployment branch. Pushes to that branch rebuild your site, and saves in the Typemark editor are pushed to it. Pushes to other branches never change your live site. On Pro and Enterprise, a pull request into the deployment branch gets a [preview](https://docs.typemark.dev/github/previews), and you can [work on other branches in the editor](https://docs.typemark.dev/editor/branches).

## Your deployment branch

When you connect a repository, the deployment branch starts as the repository's default branch on GitHub, whether that's `main`, `master` or something else. You can pick another branch before you click **Connect**: the list has every branch of the repository, and you can type to find one. **Settings** > **GitHub** shows the branch under **Publishes from**.

The Typemark editor commits to the deployment branch, unless you switch to a [branch in the editor](https://docs.typemark.dev/editor/branches).

### Changing it

The project owner can move the site to another branch at any time:

<Steps>
  <Step title="Choose the branch">
    In **Settings** > **GitHub**, click **Change branch** and pick a branch from the list. Branches marked **Protected** have protection rules on GitHub.
  </Step>
  <Step title="Confirm">
    Click **Switch branch** and confirm. Typemark checks that the branch exists and has a `typemark.json` at its root, then switches in the background.
  </Step>
</Steps>

When it switches, Typemark:

1. Pushes any saves that haven't reached GitHub yet to the old branch, so nothing is left behind. If GitHub won't take them there (the branch is protected or was deleted), they go to a new branch named `typemark/unpushed-<date and time>`, and the deployment says so.
2. Rebuilds your whole site from the new branch. Readers get the pages on the new branch, and pages that only exist on the old one come off the site. A different `docs_root` on the new branch is picked up too.
3. Pushes editor saves to the new branch from then on, and rebuilds when you push to it.

The switch publishes the new branch straight away, even if you [publish manually](https://docs.typemark.dev/configuration/publishing#manual-deploy). It shows under **Deployments** as **Switch to branch** followed by the branch name; if it couldn't happen, the reason is there and your site stays on the old branch.

<Callout type="warning">
  If the new branch's protection rules don't let Typemark push (for example, they require pull requests), your saves in the editor still go live but can't reach GitHub. Each one shows as a failed push under **Deployments**. Allow the Typemark app to push to the branch, or publish from a branch it can push to.
</Callout>

Your site can't switch to a branch that:

- doesn't exist on GitHub, or has no `typemark.json` at the repository root (or one that isn't valid JSON);
- uses Git submodules, or is over 100 MB;
- is open as a [branch in the Typemark editor](https://docs.typemark.dev/editor/branches). Delete it there first.

## Review changes with pull requests

Feature branches don't change your live site, so you can use them for drafts and review:

<Steps>
  <Step title="Create a branch">
    ```bash
    git checkout -b docs/auth-guide
    ```
  </Step>
  <Step title="Commit and push">
    ```bash
    git add guides/authentication.mdx
    git commit -m "docs: add authentication guide"
    git push origin docs/auth-guide
    ```

    Your live site doesn't change.
  </Step>
  <Step title="Open a pull request">
    Open a pull request into the deployment branch and get it reviewed on GitHub. On Pro and Enterprise, Typemark builds a [preview](https://docs.typemark.dev/github/previews) of the site with your changes and comments on the pull request with its link.
  </Step>
  <Step title="Merge">
    Merging pushes to the deployment branch, and Typemark rebuilds your site.
  </Step>
</Steps>

You can do the same without leaving Typemark: create a branch in the editor, and open the pull request from there. See [Branches in the editor](https://docs.typemark.dev/editor/branches).

<Callout type="tip">
  Working solo or in a small team? Committing straight to the deployment branch, from Typemark or Git, is simpler and works fine.
</Callout>

## Projects without GitHub

A project that isn't connected to GitHub publishes from one branch, with nothing to configure. Every save in the editor commits to it, unless you work on a [branch in the editor](https://docs.typemark.dev/editor/branches) and merge it when it's ready.
