---
title: Share work with git
description: Share your work and bring in the team's with one button, Sync, or with a branch and pull request for each file.
---

Dex shares work through your project's git repository, so you never need a terminal for it. Choose how in **Settings** → **General**, under **Sharing work**:

- **Sync** (default): one button saves your work, brings in the team's, and shares yours. Use it to see each other's changes as soon as you press it.
- **Pull requests**: each file gets its own branch, and work reaches the team when its pull request merges. Use it when every change needs a review first.

Dex runs git with your own setup and credentials. It never asks for a password, never force-pushes, and never rewrites a commit you've pushed.

## Sync your work

Click **Sync** at the top right of the canvas to open the Sync panel, then press **Sync** in it. One press:

1. Switches you to the sync branch, `dex/sync`, taking your uncommitted changes with you.
2. Commits your changes, with a message that lists the files you changed.
3. Fetches and merges the team's work from the sync branch.
4. Merges the base branch, such as `main`, so the sync branch stays up to date.
5. Pushes, and tries again if a teammate pushed first.
6. Installs what came in, such as a teammate's Dex update, then asks you to restart.

The Sync panel lists what's waiting: your changed files, commits not shared yet, and what's new from the team. Sync runs only when you press it. If a step fails, the panel says why and what to do next. Once your changes are committed, they stay committed on your computer, and **Try again** picks up where Sync stopped. Clashes and protected branches have their own steps, below.

## Why Sync rarely conflicts

A merge conflict happens when two people change the same lines of the same file. Dex lays out its files so that this is rare:

- **Each person has their own folder.** In each file, your canvas, views and specs are in `people/<you>/`, so your changes and a teammate's touch different files.
- **Comments only grow.** Each file's `comments.jsonl` gets a new line for every comment, and git keeps both sides' lines.
- **Specs merge by paragraph.** When two people change the same paragraph of a spec, Dex keeps both versions instead of stopping the merge.
- **The contributor list merges by person**, so two new contributors don't clash.
- **Dependencies settle themselves.** When only `package.json` and lockfiles clash, Dex keeps the newer Dex and both sides' other changes.

Dex writes these merge rules into `.gitattributes` for you.

## When the same lines changed

If you and a teammate did change the same lines, Sync undoes the merge and keeps your commit. Then it shows the files that clash, with three ways forward:

- **Keep theirs and update**: takes the team's version of the lines that clash. Your version goes in **Saved**, where you can restore each file.
- **Keep mine**: keeps your version of the lines that clash.
- **Ask agent to combine**: your agent merges the two versions and finishes the Sync.

## When the sync branch needs a pull request

If branch protection stops pushes to the sync branch, Sync says **Needs a pull request**. Choose **Open pull request**: Dex moves your commits to a branch named after the file, pushes it, and asks your agent to open the pull request.

## Use pull requests instead

With **Pull requests** chosen, the top right of the canvas shows your branch and its next step, which opens **Branch and changes**:

| When you're | The button says |
| --- | --- |
| On the base branch | **New branch** |
| Changing files | **Commit** |
| Ahead of the remote, or not pushed yet | **Push** |
| Pushed, with no pull request | **Open PR** |
| Waiting on a pull request | **Waiting for review**, **Checks failing** or **Conflicts** |
| Approved and passing | **Merge** |

A new branch is named after the file, such as `dex/checkout`. **Open PR** asks your agent to push, write the pull request from your repository's template, and reply with its link. When the base branch has changes your branch doesn't, the canvas offers **Bring them in**, which merges them into your branch.

To show a pull request's state and merge it, Dex uses the [GitHub CLI](https://cli.github.com) when you're signed in with `gh auth login`, or the credential git uses for an HTTPS remote. **Merge** appears only when GitHub says the pull request can merge, so your branch rules still apply.

## Git settings

The settings are saved in `dex.config.ts`, so commit them to share them with the team:

```ts
export default defineConfig({
	git: { share: "sync", syncBranch: "dex/sync", base: "main", prefix: "dex/" },
});
```

| Setting | Default | What it sets |
| --- | --- | --- |
| `share` | `"sync"` | How the team shares work: `"sync"` or `"pull-requests"`. |
| `syncBranch` | `"dex/sync"` | The branch Sync shares on. Dex creates it when it doesn't exist. |
| `base` | The remote's default branch | The branch Sync keeps up with, and pull requests merge into. |
| `prefix` | `"dex/"` | The start of each new branch's name. |

`dex create` starts a git repository for a new project, unless the folder is in one already. It adds no remote, so add yours with `git remote add origin <url>`.
