显示HN:Deff – 在你的终端中并排查看Git差异
Show HN: Deff – side-by-side Git diff review in your terminal

原始链接: https://github.com/flamestro/deff

## Deff:一个用于Git Diff审查的Rust TUI工具 Deff是一个交互式的、基于终端的工具,用于并排审查Git diff。它提供语法高亮、新增/删除行着色以及通过键盘、鼠标和Vim风格的移动进行导航等功能。 **安装** 通过shell脚本非常简单:`curl -fsSL https://raw.githubusercontent.com/flamestro/deff/main/install.sh | bash`。 **使用方法** 包括将本地分支提交与上游比较(默认)、使用`--base`和`--head`指定自定义范围,以及使用`--include-uncommitted`包含未提交的更改。您还可以使用`--theme dark|light`选择主题。 Deff允许在diff中搜索(`/`),标记文件为已审查(`r`),并本地持久化审查状态。它需要Rust工具链(Cargo)和Git。有关架构和扩展的更多详细信息,请参阅项目的文档。发布构建通过GitHub Actions自动化。

## Deff:一款新的终端 Git Diff 工具 一款名为 **deff** 的新型 Rust 终端 UI 工具已发布,用于并排查看 Git diff。它提供语法高亮、行着色、键盘/鼠标导航(包括 Vim 风格的移动和搜索),并支持查看未提交的更改。开发者正在寻求反馈。 Hacker News 上的讨论强调了对更好的终端 diff 工具的需求,尤其是在远离 IDE 并利用编码代理的工作流程中。虽然 **delta** 和 **icdiff** 等工具已经存在,但用户希望拥有诸如针对代理反馈的差异内评论功能,以及更好地处理大型文件(5k+ 行)的能力。**Difftastic** 也被提及,它是一种独特的选项,通过解析语法树来减少噪音。 采用的关键挑战在于与成熟的工具(如 `git difftool`)以及现有工作流程的熟悉度竞争。`deff` 在大型 diff 上的速度和性能对其成功至关重要。
相关文章

原文

My name is deff

deff is a Rust TUI: interactive, side-by-side file review for git diffs with per-file navigation, vertical and horizontal scrolling, syntax highlighting, and added/deleted line tinting.

Run the installer script from this repository:

curl -fsSL https://raw.githubusercontent.com/flamestro/deff/main/install.sh | bash

Installer source: https://github.com/flamestro/deff/blob/main/install.sh

The script checks for cargo, clones this project into a temporary directory, installs it, and removes the temporary checkout.

If you have local edits (including untracked files) and want to review them before committing, run:

deff --include-uncommitted

This opens the side-by-side review so you can check exactly what changed in your working tree.

  • upstream-ahead strategy (default) to compare local branch changes against its upstream
  • range strategy for explicit --base / --head comparison
  • Optional --include-uncommitted mode to include working tree and untracked files
  • Side-by-side panes with independent horizontal scroll offsets
  • Keyboard and mouse navigation (including wheel + shift-wheel)
  • Vim-like motion navigation (h/j/k/l, g/G, Ctrl+u/Ctrl+d)
  • In-diff search (/ + Enter, then n / N to navigate matches)
  • Per-file reviewed toggles (r) with local persistence under .git
  • Language-aware syntax highlighting and line-level add/delete tinting

Single-line change view:

Single-line change example

Multi-line change view:

Multi-line change example

deff
deff --strategy upstream-ahead
deff --strategy range --base origin/main --head HEAD
deff --strategy range --base origin/main --include-uncommitted
deff --theme dark

Show help:

Local Build and Usage Flow

Prerequisites:

  • Rust toolchain (cargo)
  • git
  • Interactive terminal (TTY)
  1. Build locally:

    cargo build --release --locked
    ./target/release/deff --help
  2. Optionally install it to your local Cargo bin path:

    cargo install --path .
    deff --help
  3. Run it inside any git repository you want to review:

    cd /path/to/your/repo
    
    # default: compare local branch commits vs upstream
    deff
    
    # explicit range
    deff --base origin/main --head HEAD
    
    # include uncommitted + untracked files
    deff --base origin/main --include-uncommitted

If your branch has no upstream configured, use the explicit --base flow.

Theme selection:

  • By default, deff prefers a dark syntax theme (better for black/dark terminals).
  • Use --theme auto|dark|light to control rendering for your terminal.
  • --theme takes precedence over DEFF_THEME=dark|light.

Search and reviewed workflow:

  • Press / to enter a search query for the current file (searches both panes).
  • Press Enter to apply the query, then use n / N to jump matches.
  • Press r to mark the current file reviewed/unreviewed.
  • Reviewed state is persisted locally in .git/deff/reviewed/ and keyed by comparison scope + file content hash.

This repo ships with .github/workflows/release.yml.

  • Trigger: push a tag like v0.1.0
  • Builds release artifacts for Linux and macOS targets
  • Creates a GitHub release and uploads tarballs + SHA256 files

Architecture and Extension Guide

For a module-level map and extension plan, see docs/architecture.md.

联系我们 contact @ memedata.com