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

# Git Worktrees

> Every run executes in an isolated Git worktree.

# Git Worktrees

Every run executes in an isolated Git worktree. Your main branch stays clean — no half-finished code, no broken builds, no risk of corruption from a misbehaving agent.

## How it works

When you run `gump run`, Gump creates a worktree in `.gump/worktrees/run-<uuid>` attached to branch `gump/run-<uuid>`, runs all steps inside it, and commits a snapshot after every agent step.

## Worktree modes

Each step type has a default worktree mode, overridable:

| Mode         | Description                                                                    |
| ------------ | ------------------------------------------------------------------------------ |
| `read-write` | The agent can read and modify the worktree (default for `code`)                |
| `read-only`  | The agent can read; guard enforces no writes (default for `split`, `validate`) |
| `none`       | No worktree — temp directory. The state is the only I/O channel                |

`read-only` is enforced via the `no_write` guard (post-step check). OS-level sandboxing is planned for day 2.

## Parallel worktrees

When `parallel: true` is set on a split or a group, each branch gets its own worktree. Merge is sequential by declaration order. Same file modified by two branches = fatal.

## Apply

`gump apply` merges the run's branch into your current branch with a `Gump-Run: <uuid>` trailer. `gump apply --run <uuid>` targets a specific run.

## Retry behavior

In retry, `worktree: reset` means `git reset --hard` + `git clean -fd`. Without the override, the worktree is kept as-is (`keep`).

## Cleanup

```bash theme={null}
gump gc --keep-last 10
```

Removes old worktrees, branches, and run artifacts. Unapplied runs prompt for confirmation.

## Dirty check

Before creating a worktree, Gump checks that your working directory is clean. `.gump/` is excluded from this check.
