Dffy 用 Rust 打造終端機 Git 差異檢視工具
Dffy: A fast terminal-native Git diff viewer, written in Rust
大型 Git 變更常要等很久才看得到差異,Dffy 會先顯示找到的檔案,再於背景繼續處理。
- 它用 Rust 撰寫,可在終端機裡用檔案樹瀏覽差異,也能切換並排或整合檢視。
- 把結果輸出到管線時,則會直接列印差異。作者測試 Linux v6.0 到 v6.1 的 13,168 個變更檔案,Dffy 顯示第一行變更用了 9.5ms。
- 作為 Git 分頁器讀取 48MB 差異內容時,約使用 3.0MB 記憶體。它也能監看檔案變動,並整合到 Git 的分頁器與互動式挑選流程。
AI 伴隨問答
針對這篇報導有疑問?可直接點選快捷問題或向 AI 追問背景脈絡與技術細節:
A terminal diff viewer for git, written in Rust.
Built for large repositories, up to the size of the Linux kernel.
dffy # everything you haven't committed dffy main..HEAD # any revision git understands
Install
brew install --cask amalucelli/tap/dffy # or curl -fsSL https://raw.githubusercontent.com/amalucelli/dffy/main/install.sh | sh # plus the experimental Markdown renderer: … | sh -s -- --plugin markdown
docs/install.md covers mise, building from source and the renderer plugins. Then try it in any repository: dffy HEAD~10.
About
dffy is a diff viewer for the terminal. Run it in a git repository and it opens a full-screen view of your changes: a file tree on the left, the diff on the right, split or unified. Pipe it, and it prints the diff instead.
It's built for big diffs. Instead of computing the whole diff up front, dffy shows the first files as soon as it finds them and works on the rest in the background, so a 13,000-file change opens as fast as a one-line fix.
It fits into how you already work. Every action is a single key, the layout adapts from a wide monitor down to a phone over SSH, and dffy can stand in for git's pager, git add -p filter and difftool. Settings live in a plain config file you can keep with your dotfiles.
Why dffy
dffy builds on tools I like: the terminal review flow of lumen, the review UX of hunk, and the rendering of diffs.com (Pierre's @pierre/diffs). None of them fit how I work. lumen centers on AI features I didn't want in a diff viewer. hunk is TypeScript on a JavaScript runtime, and I wanted a single native binary that stays fast on huge repos. diffs.com runs in the browser. So I built a native terminal diff viewer that works the same on a laptop and over SSH from a phone.
Features
Fast
- ⚡ Opens the Linux v6.0..v6.1 diff in 9.5ms and loads the rest in the background.
- 👀
--watchrepaints as you edit, stage and commit.
Reading diffs
- 🪟 Split or unified, picked by terminal width.
- 🌈 Syntax highlighting for 18 languages, with changed words emphasized.
- 🌳 A syntax-aware diff (
d) that marks reformatted (~) and moved (») code. - 🔁 Renames detected the way git detects them.
Navigation
- 🗂️ A file tree, a fuzzy file picker and search across the diff.
- 🎯 Each file opens at its first change, and
n/Njump between changes. - ⌨️ Single-key actions, with a command panel on
space.
Git
- 🧾 Staged, unstaged and untracked changes in one view, or any revision.
- 📟 Works as git's pager,
git add -pfilter and difftool. - 📁 Compares files and folders outside a repository too.
Anywhere
- 📱 Works on phones over SSH, with plain-letter keys and a frameless layout.
- 🖱️ Mouse selection that copies over SSH.
- 🎨 16 themes and a config file for your dotfiles.
- 🧩 Renderer plugins (experimental), such as Markdown diffed as rendered text.
Usage
dffy # staged, unstaged and untracked changes dffy --staged # what's staged (git diff --cached) dffy HEAD~3 # a revision against the working tree dffy main...feature # changes since the merge base dffy show HEAD # a commit with its message dffy main.. -- src/ # limited to paths dffy a.txt b.txt # two files or folders, no repository needed dffy --watch # refresh on every change dffy --syntax v6.0 v6.1 # diff by syntax dffy --stat main.. # also --name-only, --name-status, --exit-code
With git:
git config --global core.pager dffy
git config --global interactive.diffFilter "dffy --color-only"In the viewer, n/N move between changes, f/F between files, / searches, o finds a file, space lists commands and q quits. ~/.config/dffy/config holds key = value lines; dffy config --default lists every key with its default.
Comparison
dffy |
hunk |
lumen |
difftastic |
delta |
diff-so-fancy |
diff |
|
|---|---|---|---|---|---|---|---|
| Interactive viewer with a file tree | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
| Watch mode | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
| git's pager (reads a diff on stdin) | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ❌ |
git add -p filter |
✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
| Syntax highlighting | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
| Changed-word emphasis | ✅ | ✅ | ✅ | ✅ | ✅ | 🟡 | ❌ |
| Syntax-aware diff | ✅ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
| Split and unified, picked by width | ✅ | ✅ | ❌ | 🟡 | 🟡 | ❌ | 🟡 |
| Mouse | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
| Compares files outside a repository | ✅ | 🟡 | ❌ | ✅ | ✅ | 🟡 | ✅ |
| Plugins or extensions | 🟡 | 🟡 | ❌ | ❌ | ❌ | ❌ | ❌ |
| Single native binary | ✅ | 🟡 | ✅ | ✅ | ✅ | ❌ | ✅ |
| AI or agent annotations | ❌ | ✅ | 🟡 | ❌ | ❌ | ❌ | ❌ |
| Other VCSs (Jujutsu, Mercurial, Sapling) | ❌ | ✅ | ✅ | ✅ | ✅ | 🟡 | — |
🟡 means partial support; docs/benchmarks.md explains each one. All seven are open source. GNU diff is GPL-3.0-or-later and the rest are MIT. Checked against hunk 0.25.0, lumen 2.32.0, difftastic 0.72.0, delta 0.20.1, diff-so-fancy 1.4.14 and GNU diffutils 3.10; docs/benchmarks.md links the source for every cell.
Benchmarks
Opening Linux v6.0..v6.1 (13,168 changed files, a 48MB patch) in a viewer, time until the first changed line is on screen:
dffy |
lumen 2.32.0 |
hunk 0.25.0 |
|
|---|---|---|---|
| The v6.0..v6.1 range | 9.5ms | 12.4s | 17.7s |
| The working tree (5 files changed) | 63ms | 1.12s | 790ms |
As a pager, git diff v6.0 v6.1 | … |
217ms | n/a | 15.3s |
| Memory, opening the range | 90MB | 676MB | 4.26GB |
As git's pager, dffy streams the whole 48MB patch in 3.0MB of its own memory, about as fast as plain git diff.
docs/benchmarks.md has the machine, the method, every command and the full results, including printed output against delta, diff-so-fancy and difftastic.
Architecture
dffy is written in Rust. docs/architecture.md covers the crates, the data flow and the engine.
- 🧮 Its own diff engine: histogram and syntax-aware diffs, renames matching git's.
- 🖼️ Its own terminal renderer, with no TUI framework. A full frame takes about 200µs.
- 🌊 Streamed input and output, so the first screen doesn't wait for the whole diff.
- 🛰️ One shared watcher per repository, however many views are open.
Docs
docs/ covers every key, flag and setting: usage, the viewer, keys, configuration, themes, git integration, watch mode, renderer plugins, troubleshooting, architecture and benchmarks.
License
MIT

