LinuxCommandLibrary

tig

Browse Git repository history in a TUI

TLDR

Show the sequence of commits starting from the current one in reverse chronological order

$ tig
copy

Show the history of a specific branch
$ tig [branch]
copy

Show the history of specific files or directories
$ tig [path1 path2 ...]
copy

Show the difference between two references (such as branches or tags)
$ tig [base_ref]..[compared_ref]
copy

Browse git blame interactively (press <,> to jump to parent)
$ tig blame [path/to/file]
copy

Display commits from all branches and stashes
$ tig --all
copy

Start in stash view, displaying all saved stashes
$ tig stash
copy

Display help in TUI
$ <h>
copy

SYNOPSIS

tig [options] [rev-list-options] [log-options] [diff-options] [path...]
tig mode [options] [args]

PARAMETERS

--version
    Display the version of tig and exit.

--help
    Display the help message and exit.

--log
    Start tig in the log view (this is the default behavior).

--status
    Start tig in the status view, showing changes in the working tree and index.

--diff
    Start tig in the diff view, useful for comparing specific commits or branches.

--tree
    Start tig in the tree view, allowing browsing of a tree object's contents at a specific commit.

--blame
    Start tig in the blame view, showing line-by-line authorship for a given file.

-p, --patch
    Show the full diff (patch) for each commit directly within the log view.

--all
    Show commits from all refs (branches, tags, and remote-tracking branches).

-C
    Run tig as if it was started in the specified directory <path>.

-S
    Search for commits whose message or diff content matches the given <pattern>.

-L ,:
    Show line history for <file> from line <start> to <end> in blame view.

DESCRIPTION

tig is a free and open-source text-mode interface for Git. It functions primarily as a ncurses-based browser for Git repositories, allowing users to navigate commit history, view diffs, browse branches, and much more, all within a terminal window.

It provides a visual and interactive way to explore a Git repository without needing a graphical interface. tig excels at presenting Git objects like commits, trees, blobs, and diffs in a structured and easily traversable manner. Its capabilities include a log view, diff view, status view, tree view, blame view, and the ability to stage/unstage changes. It is highly configurable and extensible, making it a powerful tool for terminal-centric Git workflows.

CAVEATS

tig primarily functions as a viewer; while it offers some write capabilities (like staging/unstaging), it's not a full-fledged Git client for complex operations like interactive rebasing or merging. Performance might degrade slightly on extremely large repositories with millions of commits or very massive diffs, though it's generally highly optimized.

It requires a ncurses-compatible terminal environment to operate correctly.

KEYBINDINGS

tig is highly interactive and relies heavily on keyboard shortcuts for navigation and actions. Common keys include j/k for line-by-line movement, Enter to open an item (e.g., a commit or file), q to quit or go back to the previous view, s for status view, d for diff view, m for main (log) view, and / for searching.

CUSTOMIZATION

Users can extensively customize tig's behavior and appearance via a configuration file (typically located at ~/.config/tig/config or ~/.tigrc). This allows defining custom keybindings, color schemes, and command aliases to tailor the tool to individual preferences.

SCRIPTABILITY

tig supports a --batch mode and related options (--no-quit, --exit-as-pager) for scripting, enabling its use in non-interactive scenarios to extract and process Git repository information.

HISTORY

tig was created by Jonas Fonseca and first released around 2006. It was designed to provide a lightweight, fast, and intuitive text-mode interface for Git, complementing the command-line tools. Over the years, it has gained significant popularity in the Git community due to its efficiency and rich feature set, becoming a go-to tool for many developers who prefer a terminal-centric workflow. Its development has been community-driven, with contributions from many users worldwide.

SEE ALSO

git(1), git-log(1), git-diff(1), git-show(1), less(1)

Copied to clipboard