Configs2026年4月14日·1 分钟阅读

tig — Text-Mode Interface for Git History and Diff Browsing

tig is a curses-based interactive browser for Git repositories. It shows log, blame, stash, reflog, and diff views in a fast TUI — the go-to tool when you want to read Git history without leaving the terminal.

Introduction

tig has been the terminal Git browser since 2006. Built on ncurses and written in C, it's fast, universally available, and does one thing perfectly: let you navigate Git history with keyboard shortcuts. Where lazygit and gitui are full-featured TUIs, tig is the lean "just show me what changed" alternative many devs keep installed for quick inspection.

With over 13,000 GitHub stars, tig still ships in every Linux distro's repos and remains many teams' default Git viewer. It's especially great for reading history on servers (no plugins, no config, just works).

What tig Does

tig provides views: main (log + commit preview), log (full commit list), diff (unified diff), blame (annotated file), status (wd changes), stage (individual hunks), stash (stash list), grep (searchable log), refs (branches/tags). Navigate with hjkl/arrow keys, toggle views with 1–9, and use ! to revert or C to cherry-pick.

Architecture Overview

Repo
    |
[git subprocess]
   calls `git log`, `git diff`, etc.
   parses output into views
    |
[tig TUI (ncurses)]
    |
  +------+------+------+------+------+
  |      |      |      |      |      |
main  log   diff  blame status stash
    |
[Keybindings]
   h j k l / arrows, PgUp/PgDn
   1-9 switch views
   Enter expand commit
   /  search
   !  revert commit
   C  cherry-pick
   q  quit

Self-Hosting & Configuration

# ~/.config/tig/config
set main-view = id date author:abbreviated commit-title:graph=yes,refs=yes
set diff-options = --patch-with-stat
set blame-options = -C -C -C
set vertical-split = true
set diff-highlight = true

# Custom keybindings
bind main C !@git cherry-pick %(commit)
bind main R !?git rebase -i %(commit)^
bind status + !git add -p %(file)
bind diff   o !tig show %(commit)
# Common flows
tig HEAD~50..                # last 50 commits
tig --all --merges           # merge history across branches
tig log -- path/to/file      # history for one file
tig blame -C -L 50,100 file  # blame with copy-detection, lines 50-100

Key Features

  • Many views — main, log, diff, blame, status, stash, grep, refs, reflog
  • Interactive staging — stage/unstage hunks line-by-line in the TUI
  • Universal — packaged by every major distro, works on macOS/Linux/BSD
  • Keyboard-first — no mouse needed, shortcuts are discoverable
  • Custom keybinds — shell out to any git command on demand
  • Read-only-safe defaults — dangerous actions always prompt first
  • Works over SSH — no fancy graphics, runs anywhere git does
  • Tiny footprint — <1MB binary, no dependencies besides ncurses

Comparison with Similar Tools

Feature tig lazygit gitui magit (Emacs) gh
Language C Go Rust Emacs Lisp Go
Speed (huge repos) Fast Fast Fastest Slow on huge repos Fast
Feature breadth Focused Broadest Broad Broadest (Emacs) GitHub-specific
Staging hunks Yes Yes Yes Yes Limited
SSH-friendly Best Yes Yes Needs Emacs Yes
Learning curve Low Medium Medium High (Emacs) Low
Best For Quick history browsing Full git TUI Speed-first Emacs users GitHub PRs

FAQ

Q: tig vs lazygit? A: Both are TUI Git browsers. lazygit is a full-featured "one-stop shop" with richer commit editing and rebasing. tig is leaner, packaged everywhere, and has been stable since 2006. Many devs use both: lazygit for editing, tig for quick reading.

Q: Is tig still maintained? A: Yes — active maintenance, though release cadence is slow. The codebase is mature and bug-free enough that infrequent releases are fine.

Q: Can tig do interactive rebase? A: Not natively. Bind a key to !git rebase -i %(commit)^ and tig will shell out to git's built-in interactive rebase in your editor.

Q: How do I search history? A: Press / in any view to incremental-search. ? searches in reverse. The grep view runs git grep and lists matching commits.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产