# History and inspection

## The log

```bash
oak log                        # full-screen viewer on a terminal: commit list + detail pane
oak log -n 20 --oneline        # the last 20, one per line
oak log --verbose              # include each commit's changed files
oak log src/parser/            # only commits touching these paths
oak log --json                 # machine-readable
```

On your branch, the log shows your checkpoints. On `main` — `oak log` after `oak switch -d` to a main commit, or the repo's history on oak.space — it's one squash commit per merged branch, each carrying that branch's description as its message.

The viewer takes arrows, `less`/vi, and emacs keys; press `?` for the list. See [the full-screen viewers](/docs/reviewing#the-full-screen-viewers).

### Search history

```bash
oak log -S parse_header        # commits that add or remove the literal string (like git log -S)
oak log -G 'fn parse_\w+'      # commits with an added/removed line matching a regex (like git log -G)
```

### Read a remote branch's history without fetching it

```bash
oak log --remote --json --branch fix-auth--a1b2c3d4 -n 50
```

A bounded, read-only walk of the branch's history on the server. Each row is hash-verified; when the list is truncated, the output says so and gives a `--from <hash>` to continue from. Requires `--json`.

## Where am I?

```bash
oak hash                       # current HEAD commit
oak rev-parse --short HEAD     # Git-compatible form, for scripts
oak branch --show-current      # current branch name
oak info                       # repo, branch, parent, remote, and linked-repo details
oak open                       # open this repo on oak.space (--print to just print the URL)
```

## Inspect files and trees at a commit

These read committed content without changing your working tree — useful for agents that need one file from another commit without a checkout.

```bash
oak file inspect src/main.rs --at 3f9fab02            # one file at a commit
oak file inspect src/main.rs --at HEAD --output /tmp/main.rs
oak file inspect src/main.rs --at <full-hash> --remote   # from the server, no clone needed

oak tree inspect --at HEAD --max-files 500 --json      # a commit's whole tree, bounded
oak refs inspect --json                                # every local branch and its head
```

`file inspect` caps output at 16 MiB by default (`--max-bytes` to change it). All three take `--json`.

## Browse files at any commit

`oak checkout <hash>` (or `oak switch -d <hash>`) puts your working tree at an old commit with a detached HEAD. On oak.space, every commit page has **Browse files at this commit**, and the API serves trees and raw files by commit — `GET /api/{owner}/{name}/tree/{commit}` and `/raw/{commit}/{path}`; see [the API reference](/docs/api#commits-and-content).

## Save uncommitted work without committing

```bash
oak change capture --json                    # snapshot uncommitted changes as immutable objects
oak change capture src/ --json               # …or only part of them
oak change export <capture-id> --output work.zip
```

`oak change capture` stores your current uncommitted changes durably — like a stash that doesn't touch the working tree or move any branch — and prints a capture id. `oak change export` writes one capture out as a self-contained zip (a manifest plus the changed files) you can hand to someone else.
