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

# Usage

Run DiffHub in cmux or a browser and choose a base branch.

## cmux

```bash
npx diffhub@latest cmux
```

Run that inside any git repository. DiffHub starts the local viewer and opens it in a cmux browser split.

cmux mode currently expects `cmux.app` on macOS at `/Applications/cmux.app`.

Use these flags when you need them:

```bash
# Use a different base branch
diffhub cmux --base develop

# Point at a repo in another directory
diffhub cmux --repo ~/projects/my-app
```

## Browser

```bash
npx diffhub@latest
```

That starts the same viewer in your default browser.

## Commands

| Command | Description                              |
| ------- | ---------------------------------------- |
| `serve` | Start DiffHub in a normal browser window |
| `cmux`  | Start DiffHub in a cmux browser split    |

## `serve` options

| Flag                  | Default | Description                 |
| --------------------- | ------- | --------------------------- |
| `-p, --port <port>`   | `2047`  | Port to serve on            |
| `-r, --repo <path>`   | `cwd`   | Path to the git repository  |
| `-b, --base <branch>` | auto    | Base branch to diff against |
| `--no-open`           | —       | Skip automatic browser open |

## `cmux` options

| Flag                  | Default | Description                 |
| --------------------- | ------- | --------------------------- |
| `-r, --repo <path>`   | `cwd`   | Path to the git repository  |
| `-b, --base <branch>` | auto    | Base branch to diff against |

## Examples

```bash
# Open in cmux
diffhub cmux

# Use a different base branch in cmux
diffhub cmux --base develop

# Point cmux mode at a repo in another directory
diffhub cmux --repo ~/projects/my-app

# Use a different port in browser mode
diffhub --port 3000

# Don't open the browser automatically
diffhub --no-open
```

## Base branch detection

DiffHub auto-detects the base branch in this priority order:

1. `origin/main`
2. `origin/master`
3. `origin/develop`
4. `origin/dev`
5. Local `main`, `master`, `develop`, `dev`

Override with `--base <branch>` or the `DIFFHUB_BASE` environment variable if your repo uses a different naming convention.

## Keyboard shortcuts

| Key        | Action                         |
| ---------- | ------------------------------ |
| `j`        | Next file                      |
| `k`        | Previous file                  |
| `s`        | Toggle split / unified view    |
| `/` or `t` | Focus file filter              |
| `r`        | Force refresh diff             |
| `c`        | Collapse / expand current file |
| `Shift+C`  | Collapse all files             |
| `Shift+E`  | Expand all files               |

## Environment variables

| Variable                | Description                                     |
| ----------------------- | ----------------------------------------------- |
| `DIFFHUB_REPO`          | Path to the git repository (overrides cwd)      |
| `DIFFHUB_BASE`          | Base branch override (overrides auto-detection) |
| `DIFFHUB_DEBUG`         | Set to `1` for verbose git command logging      |
| `DIFFHUB_DISABLE_WATCH` | Set to `1` to disable file system watching      |