---
title: Branches and pull requests
description: "Branch, commit, push and open a pull request from the canvas, without typing git. Dex says the next step; the agent writes the pull request."
---

When Dex is in a git repository, the canvas shows one pill at the top right: your branch and how many changes it has, such as `dex/checkout · 2 changes`. With nothing to commit, it shows the next step instead. Click it to open **Branch and changes**. You never need a terminal for the everyday steps.

## The pill

| You are | The pill says |
| --- | --- |
| Changing files | **2 changes**, in the warning colour |
| On the base branch (`main`, or the one in Settings) | **New branch** |
| Behind your branch's copy on the remote | **Sync changes** |
| Ahead of it, or not pushed yet | **Push** |
| Pushed, with no pull request | **Open PR** |
| Waiting on a pull request | **Waiting for review**, **Checks failing** or **Conflicts**; hover for why |
| Approved and passing | **Merge** |
| Merged | **New branch**, from the base branch as it is now |

A long branch name is cut short; hover for the whole name. Once there is a pull request, **↗** beside the pill opens it on GitHub.

## Branch and changes

The panel opens under the pill, in place of the Comments panel. Git's settings are in **Settings** → **Workspace settings**. Top to bottom:

- **Branch:** the branch you are on. Its menu switches to one of the file's own branches: the ones made for it in Dex, and any branch, yours or a teammate's, with changes to it that the base branch doesn't have yet. Once a branch is merged, or its remote copy is deleted, it drops off the list. **All branches…** finds any other, and **New branch…** makes one, named after the file (`dex/checkout`). On the base branch, your uncommitted changes come with you; on any other branch, commit them first. Opening a file never changes branch, and one branch can hold work on several files.
- **3 behind main**, when the team has merged something your branch doesn't have, with **Bring in the team's latest** (see below).
- **2 changes:** a scrolling list of every changed file, grouped by Dex file, then **Other files** for files in no Dex file: each by name, with its folder under it and **New**, **Changed**, **Renamed** or **Deleted** beside it (hover for the whole path). A message to start from, which you can edit, and **Commit 2 changes**. Dex commits every change; it does not pick some. On the base branch, **New branch** comes first instead, as the main action: it takes the changes with it, and committing them to the base branch comes second.
- **Next:** the step after that, such as **Push** or **Open PR**, or why it waits.

Dex runs git itself, with your own git setup and credentials, and never asks for a password: a step that would need one fails. When a commit, push or sync fails, the toast offers **Ask agent to fix**. It refuses to switch branch with uncommitted changes ("Commit your changes first."), and it never force-pushes.

## The team's latest

When the team has merged something into the base branch that your branch doesn't have, the canvas says so: "3 new changes from the team", with **Bring them in**. Branch and changes shows it too ("3 behind main"). Dex checks when the canvas opens and every five minutes while it is focused.

**Bring them in** (or **Bring in the team's latest** in the panel) merges the base branch, as just fetched, into your branch, so nothing you pushed is rewritten. The canvas and its views then show the new designs, and the pill offers **Push** to share the merge. On the base branch itself it fast-forwards, so there is nothing to push and the pill stays **New branch**. Commit your changes first.

If Git can't merge the two, nothing comes in and your branch is left as it was. The toast offers **Ask agent to merge**, which asks the agent to merge them in, resolve the conflicts and push.

## What the agent does

**Open PR**, **Ask agent to merge** and **Ask agent to fix** are requests to your agent, in the file's comments, like any other. The agent pushes, writes the pull request from your repository's template and instructions, says where to see the files' canvases (a link when Dex is served where reviewers can reach it, otherwise their path in Dex), and replies with its link. With no agent connected, **Open PR** shows the push command and GitHub's compare link to copy instead.

## Pull requests on GitHub

To show a pull request's state and merge it, Dex asks GitHub with the [GitHub CLI](https://cli.github.com) when you are signed in (`gh auth login`), or else with the credential git already uses for an HTTPS remote. With neither, **↗** opens the pushed branch's compare page on GitHub in your browser, and the rest still works. Merge appears only when GitHub says the pull request can merge, with no check failing or still running, so your branch rules still decide.

## Settings

**Settings → Workspace settings**, under Git, sets the base branch (default: the remote's default branch) and the prefix new branches get (default `dex/`). They are kept in `dex.config.ts`:

```ts
export default defineConfig({
  git: { base: "develop", prefix: "dex/" },
});
```

Commit the change, and everyone on the team gets the same.

## A new project

`dex create` starts a git repository with a first commit for a new project, unless the folder is in one already (`--no-git` skips it). It adds no remote: add yours with `git remote add origin <url>`. `dex doctor` warns when Dex is not in a repository, or the repository has no remote.
