tig
Text-mode interface for Git.
Official WebsiteFeatures
Installation
brew install tigapt install tigpacman -S tigWhy use tig?
tig is an ncurses-based text mode Git browser. Written in C, it is extremely lightweight and fast. A tool specialized for viewing Git history, it can be used as an enhanced version of git log.
History Visualization
Clearly visualize commit history with graph display. Intuitively understand branch forks and merges.
Fast Search
Performs quickly even with large repositories. Can search diffs and commit contents rapidly.
Flexible Filtering
Can filter by diverse conditions like author, date, path, and commit message.
Multiple Views
Multiple view modes suited for different purposes like main, log, diff, tree, blob, blame, refs.
Interface
tig's main view: Displays commit history in graph format. Branch forks and merges are visually clear.
Installation
# macOS (Homebrew)
brew install tig
# Ubuntu/Debian
sudo apt install tig
# Fedora
sudo dnf install tig
# Arch Linux
sudo pacman -S tig
# Build from source
git clone https://github.com/jonas/tig.git
cd tig
make prefix=/usr/local
sudo make install prefix=/usr/localBasic Usage
Startup Commands
# Show history of current branch
tig
# Show specific branch
tig main
tig feature/new-ui
# Show history of specific file
tig README.md
tig src/main.rs
# Show commits in specific range
tig v1.0..v2.0
# Open in blame view
tig blame README.md
# Open in status view
tig status
# Show stash
tig stashKey Bindings
| Key | Action | Description |
|---|---|---|
j / k | Move up/down | Move cursor up/down |
Enter | Select | Show commit details/diff |
m | Main view | Main commit history display |
d | Diff view | Show diffs |
l | Log view | Detailed log display |
t | Tree view | Show file tree |
b | Blame view | Show per-line change history |
r | Refs view | Branch and tag list |
s | Status view | Show status |
/ | Search | Search within view |
n / N | Next/previous result | Move between search results |
? | Help | Show key binding list |
q | Quit/back | Close view/exit tig |
Main View Modes
Main View
Display commit history in graph format. This is the default view.
# Operations in main view
Enter # Show diff of selected commit
t # Show file tree at commit time
C # Cherry-pick
R # Revert
G # Filter with --grep option
F # Filter by pathStatus View
Display information equivalent to git status. Staging and committing is also possible.
# Operations in status view
u # Stage/unstage file
! # Checkout (discard changes)
C # Commit
M # Merge
Enter # Show diffBlame View
Show when and by whom each line was changed.
# Open in blame view
tig blame src/main.rs
# Operations in blame view
Enter # Show diff of commit that changed this line
, # Show blame of parent commit (state before change)
< # Show blame of previous commitRefs View
Display list of branches and tags. Allows checkout and branch operations.
# Operations in refs view
C # Checkout selected branch
! # Delete branch
Enter # Show commit history of branchPager Mode
tig can display git command output as a pager.
# Display git log output with tig
git log --oneline | tig
# Display git show output with tig
git show HEAD | tig
# Display git diff output with tig
git diff | tig
# Set as PAGER environment variable
export GIT_PAGER=tigConfiguration & Customization
Configuration File
Customize in ~/.tigrc.
# ~/.tigrc
# Display settings
set main-view = line-number:no,interval=5 id:yes date:relative author:abbreviated commit-title:yes,graph,refs,overflow=no
# UTF-8 support
set line-graphics = utf-8
# Color settings
color cursor white blue bold
color title-focus white blue bold
color title-blur white default
# Number of context lines in diff
set diff-context = 5
# Commit order
set commit-order = default
# Tab width
set tab-size = 4
# Horizontal scroll
set horizontal-scroll = 33%
# Mouse support
set mouse = yes
set mouse-scroll = 5Customize Key Bindings
# ~/.tigrc - Custom key bindings
# Cherry-pick commit
bind main P !git cherry-pick %(commit)
# Create branch
bind main B !git checkout -b "%(prompt Enter branch name: )"
# Reset commit
bind main H !git reset --hard %(commit)
# Start rebase
bind main R !git rebase -i %(commit)
# Push
bind status P !git push origin HEAD
# Pull
bind status U !git pull --rebasePractical Usage Examples
Investigate Change History of Specific File
# Show full history of file
tig -- src/main.rs
# Show changes in specific date range
tig --after="2024-01-01" --before="2024-06-30" -- src/
# Show changes by specific author
tig --author="John" -- src/Code Review
# Check diff between two branches
tig main..feature/new-ui
# Show specific commit range
tig abc1234..def5678
# Check unmerged commits
tig origin/main..HEADTips & Tricks
- *tig is designed as a read-only tool, but you can add write operations through configuration
- *Press
eto open editor (uses$EDITORor$TIG_EDITOR) - *In blame view, press
,to show blame of the line's previous state - *Press
Oto change display options for current view - *For large repositories, limit display count like
tig -n 100for faster startup - *Press
:to open tig prompt, where you can dynamically change options