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

# bisect

> Find the commit that introduced a bug

You use bisect to find the commit that introduced a bug. It checks out the middle commit between one that has the bug and an older one that does not, then repeats on the half you mark.

The search follows each commit's previous commit, so it stays on one line of history. If the bug came in through a merge, the result is that merge. Check out the other branch and run bisect there to continue.

```bash theme={null}
dv bisect start [<bad> [<good>...]]
dv bisect bad [<ref>]
dv bisect good [<ref>...]
dv bisect skip [<ref>...]
dv bisect reset [<ref>]
dv bisect log
dv bisect run <command> [<arg>...]
```

Start a search, mark the current commit as bad, and name an older commit that does not have the bug:

```bash theme={null}
dv bisect start
dv bisect bad
dv bisect good <older-commit>
```

Test the files, then mark what you found:

```bash theme={null}
dv bisect good
dv bisect bad
```

`dv bisect run` runs a command at each step.

* Exit code 0 means the bug is not in this commit.
* Exit code 125 skips a commit you cannot test.
* Exit codes 1 to 127 mean the bug is in this commit.
* Exit code 128 or higher stops the search.

The command runs in the workspace root. `DV_BISECT_COMMIT` is the commit under test. Put `--` before arguments that start with a dash. Files the command creates are discarded before the next checkout.

```bash theme={null}
dv bisect run -- ./test.sh
```

Uncommitted changes are refused before the first test, so a local edit cannot hide the commit under test.

`dv bisect reset` stops the search and checks out the branch or commit you were on when it started.


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