A tiny TUI around git diff.
git clone https://github.com/Julius-IX/gdiff.git
cd gdiff
cargo install --path .gdiff # working tree vs HEAD~X
gdiff <commit> # <commit> vs <commit>~X
gdiff --follow # slide both sides back: HEAD~0 vs HEAD~1, then HEAD~1 vs HEAD~2, ...
gdiff <commit> -f # same, starting from <commit>
gdiff --no-pager # ignore your git pager/color configX starts at 0 and goes up to the number of commits reachable from the starting commit.
With an explicit commit, X can also go negative: ← past 0 steps towards newer commits (along HEAD's first-parent chain) up to HEAD.
In that direction <commit> is the old side and the newer commit is the new side.
| Key | Action |
|---|---|
← / → or h / l |
Compare against a newer / older commit |
↑ / ↓ or j / k |
Scroll the diff |
PgUp / PgDn |
Scroll a page |
q / Esc |
Quit |
gdiff renders diffs through the pager git itself would use for git diff: pager.diff if set, otherwise the result of git var GIT_PAGER ($GIT_PAGER -> core.pager -> $PAGER).
Tools such as delta and bat work without additional setup.
A TUI cannot hand the terminal to an interactive pager. Instead, gdiff pipes the diff through the configured command non-interactively, parses the resulting ANSI output, and displays it in its own viewport. Scrolling is handled by gdiff.
- Passthrough pagers:
less,moreandcatare skipped. Git's native colors are used instead. - bat: requires a language to highlight diffs (e.g.
bat -l diff). gdiff setsBAT_OPTSto force color output and disable paging. - delta: cannot detect the terminal width when its output is piped. gdiff sets
COLUMNS; if side-by-side layouts render incorrectly, setwidthin your delta configuration. - Failures: if the pager exits with an error, the message is shown in the diff pane. Use
--no-pagerto bypass it.
- With no arguments,
X=0showsgit diff HEAD(staged + unstaged), not plaingit diff. - With an explicit commit,
X=0compares the commit to itself, so you'll see "(no changes)" until you press→. - Pagers are launched with
sh -c, so on Windows you need Git for Windows.