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

# Branches and changes

> Review your edits, commit them, open a pull request, switch branches, and preview branches of synced repositories

Every edit made in the [Context Hub](https://docs.getnao.io/nao-agent/chat/admin/context-hub.md), by you or by the context editing chat, lands in **your own workspace**: a Git worktree of the [connected repository](https://docs.getnao.io/nao-agent/chat/admin/git.md) that only you use. The **Changes** tab is where you review those edits, commit them on a branch, and open a pull or merge request.

> [!NOTE]
>
> Your workspace is separate from the **live context** the agent reads. Nothing you save, commit, or push changes what the agent sees until the pull request is merged and an admin clicks **Pull latest** in **Settings** → **Git**, or the deployment syncs.

## Review your changes

Open the **Changes** tab next to **Files** (or **Context** in the doc view). The badge counts the files you changed.

![The Changes tab listing three edited files, with the diff of the glossary open](https://mintcdn.com/naolabs/h7AV-NCOeb1k4Pm-/images/nao-agent/branches/changes-panel.png?fit=max\&auto=format\&n=h7AV-NCOeb1k4Pm-\&q=85\&s=1eeded24b12aa533b58bed2744894f8c)

* Click a file to open its diff. Markdown diffs can be read **Rendered** or as **Lines**. nao picks **Lines** when the header changed, since the rendered view doesn't show it.
* Use the checkbox next to a file to leave it out of the next commit.
* Use the undo icon next to a file to discard its changes, or the one next to **Changes** to discard them all. Discarding can't be undone.

## Commit and open a pull request

**1. Write the commit message**

Type a message, or click the sparkles icon (**Write it for me**) to let nao write one line from the selected changes with the project's model.

![A commit message written by nao above the Commit & push button](https://mintcdn.com/naolabs/h7AV-NCOeb1k4Pm-/images/nao-agent/branches/commit-message.png?fit=max\&auto=format\&n=h7AV-NCOeb1k4Pm-\&q=85\&s=5e88f11f9ce60becb4e0e621dedfae28)

**2. Commit and push**

Click **Commit & push**, or press `Cmd+Enter`. When only some files are selected, the button reads **Commit N of M & push**.

You never commit to the default branch. Committing from `main` first creates a branch for you, named like `nao/context-edits-…`. Use **Rename branch** in the menu next to the button to choose another name.

**3. Review the pull request**

The first push opens a pull request (a merge request on GitLab) and shows a link to it, such as **#12**. Later pushes from the same branch update that pull request instead of opening another one.

If the provider can't create the pull request, nao still pushes the branch and asks you to open the pull request yourself.

Who appears on the commit depends on the [Git setup](https://docs.getnao.io/nao-agent/chat/admin/git.md#choose-how-nao-reaches-your-repository): with a shared access token, the token's account commits and you are added as co-author and named in the pull request. With personal accounts, you are the author and nao is co-author.

### Commit without pushing

The menu next to **Commit & push** also offers **Commit without pushing**. Commits that are not pushed yet are listed under **Outgoing**. Click **Push & open PR** when you are ready, or the undo icon to **Undo last commit, keeping its changes**. Only a commit that has not been pushed can be undone.

![The menu next to Commit & push with Commit without pushing and Rename branch](https://mintcdn.com/naolabs/h7AV-NCOeb1k4Pm-/images/nao-agent/branches/commit-menu.png?fit=max\&auto=format\&n=h7AV-NCOeb1k4Pm-\&q=85\&s=f068e92cfe48478e15818458e4cffaf3)

![An outgoing commit on a new nao/context-edits branch, ready to Push & open PR](https://mintcdn.com/naolabs/h7AV-NCOeb1k4Pm-/images/nao-agent/branches/outgoing.png?fit=max\&auto=format\&n=h7AV-NCOeb1k4Pm-\&q=85\&s=e01b6b4c9a5a632d3e7feb144063af5f)

## Switch branches

The branch button at the top of **Changes** shows the branch your workspace is on. Click it to open any branch of the repository.

![The branch picker listing the repository's branches with their last author and date](https://mintcdn.com/naolabs/h7AV-NCOeb1k4Pm-/images/nao-agent/branches/branch-picker.png?fit=max\&auto=format\&n=h7AV-NCOeb1k4Pm-\&q=85\&s=a94ff3bd7da0a9dd6d824187c55f189e)

* The default branch comes first, marked **default**. Each branch shows who last committed to it and when.
* Search by name, or type `@` followed by a name to find someone's branches, such as `@alex`.
* Toggle **Mine** to only see the branches you last committed to. With a shared access token, only branches created in nao count as yours.
* Repositories with more than 1,000 branches are listed from Git directly, so every branch can still be found.

![Searching branches by author with @](https://mintcdn.com/naolabs/h7AV-NCOeb1k4Pm-/images/nao-agent/branches/branch-picker-author.png?fit=max\&auto=format\&n=h7AV-NCOeb1k4Pm-\&q=85\&s=7a895111ff0f1e876eb18f7e7602e9bb)

To start fresh work, click **New branch…** at the bottom of the list. The new branch starts from the repository's default branch.

![The Create a branch dialog](https://mintcdn.com/naolabs/h7AV-NCOeb1k4Pm-/images/nao-agent/branches/new-branch.png?fit=max\&auto=format\&n=h7AV-NCOeb1k4Pm-\&q=85\&s=60582a3688dec22e9b71ebb400215614)

### Before you switch

* Save or discard the open file, and commit or discard your changes. nao won't switch branches with uncommitted work, so nothing is lost.
* A branch someone else is working on opens **read-only**, marked with an eye icon. Switch to one of your branches, or create one, to make changes.

## Keep your workspace up to date

When the live context moves ahead of your workspace (for example after **Pull latest**), nao updates clean workspaces automatically. When it can't, an update icon appears in **Changes**. Click it to **Update File Explorer**, which moves your workspace to the default branch with the latest files. Your other branches and commits are kept.

If you have uncommitted changes, commit or discard them first.

## Preview a branch of a synced repository

Repositories that `nao sync` copies into the context, such as a dbt project listed under `repos` in `nao_config.yaml`, appear under **Synced repos**. They are read-only in nao: change them in their own repository.

Pick a branch of a synced repository to see how it would change the context before it is merged:

* nao syncs that branch and lists the files it changes compared with production.
* Click a file to see its diff.
* The pull request of the branch is linked next to the repository, such as **#99**.
* Tests compare against that branch, so you can check how the agent behaves with it. Click the flask icon to **Test this branch**.

![A branch of the synced dbt repository, with its pull request, the files it changes, and the diff of stg\_customers.sql](https://mintcdn.com/naolabs/h7AV-NCOeb1k4Pm-/images/nao-agent/branches/synced-repo-diff.png?fit=max\&auto=format\&n=h7AV-NCOeb1k4Pm-\&q=85\&s=85f5bd6927e31b2bb3a015c245e6a270)

Picking the production branch again goes back to what is in production.

Self-hosted deployments can turn off branch management for synced repositories with `NAO_CONTEXT_SYNCED_REPOS_ENABLED=false`: the **Synced repos** section of the Changes tab and their branches in the tests' branch picker go away. `nao sync` still copies them, and their files stay in the context, available to the agent.

## Without a connected repository

When no repository is connected, your edits are kept in nao as a private draft, marked **Draft · only you**. You can still **Test vs production** to see how the agent behaves with them. To commit them, [connect a repository](https://docs.getnao.io/nao-agent/chat/admin/git.md).


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