---
title: "hunk: review diffs in the terminal"
url: https://perrotta.dev/2026/11/hunk-review-diffs-in-the-terminal/
last_updated: 2026-11-29
---


[Previously]({{< ref "2025-11-04-git-diff-interactively" >}}).

**Problem statement**: how can we review a changeset in the terminal, one
hunk at a time, without staging anything?

[Hunk](https://hunk.dev/) is a terminal diff viewer. It displays the whole
changeset in one scrollable view, with a file sidebar and syntax highlighting.

Most Git subcommands we use for code review have corresponding Hunk commands.
For example, `git diff`, `git show`, `git log`, `git status`, and `git stash show`
become `hunk diff`, `hunk show`, `hunk log`, `hunk status`, and `hunk stash show`.

Install with [Homebrew](https://brew.sh/):

```shell
% brew install hunk
% hunk --version
0.25.0
```

From a Git repository, open the working tree diff:

```shell
% hunk diff
```

Unlike plain `git diff`, this includes untracked files. To exclude them:

```shell
% hunk diff --exclude-untracked
```

The [keyboard controls](https://hunk.dev/docs/start/keyboard-and-mouse/)
we need first:

- `]` / `[`: next / previous hunk.
- `.` / `,`: next / previous file.
- `j` / `k`: move down / up.
- `1` / `2` / `0`: unified / split / automatic layout.
- `?`: help. `q`: quit.

Automatic layout uses split view in wide terminals and unified view in narrow
ones. Click a file in the sidebar to jump straight to it.

Review the staging area, the last commit, or a pair of revisions:

```shell
% hunk diff --staged
% hunk show HEAD
% hunk diff HEAD~1 HEAD
```

Limit the review to a file. Here is the draft of this post:

```shell
% hunk diff -- content/posts/2026-11-28-hunk-review-diffs-in-the-terminal.md
```

To use Hunk as the [Git pager](https://hunk.dev/docs/workflows/git-pager-and-difftool/):

```shell
% git config --global core.pager 'hunk pager'
% git diff
% git show HEAD
```

Git now sends its diff output to Hunk. Unlike `hunk diff`, this does not
include untracked files. Non-diff output, such as `git log`, uses a plain-text
pager instead: `HUNK_TEXT_PAGER`, then `PAGER`, then `less -R` on macOS/Linux.

For a review that reloads as files change:

```shell
% hunk diff --watch
```

Useful when a coding agent is editing the same working tree. Leave Hunk open
in another terminal and review the changes as they arrive.

