Getting started

Introduction

Tig is a terminal browser for Git repositories and history.

Installing

macOS

brew install tig --HEAD

Ubuntu

sudo apt install tig

See: Installation and news

Invocation

CommandDescription
tigLogs
tig statusStatus
tig logLog messages and diffstat
tig blame FILEBlame
tig masterShow a branch
tig test..masterShow difference between two branches
tig FILEShow history of file
tig v0.0.3:READMEShow contents of file in a specific revision
tig -C /repo/pathRun in dir /repo/path (like git -C)
tig refsBranches, remotes, tags
tig stashStashes

You can substitute git log → tig.

See: tig(1) examples, revision specification

Shortcut keys

Switching views

ShortcutDescription
mMain view
dDiff
lLog
tTree (files)
bBlame
sStatus
cStage
yStash
gGrep
pPager
fBlob (file)
rRefs
hHelp

See: View switching

All views

ShortcutDescription
<enter>Open selected line
<tab>Move focus to next view
RRefresh
OMaximize current view
qClose view
QClose all (quit)
,Move to parent

See: View manipulation

Cursor navigation

ShortcutDescription
/Search
?Search backwards
n NNext/previous match
j kUp/down
<home>First line
<end>Last line
<space>Page down
-Page up

See: Cursor navigation

Option toggles

ShortcutDescription
oOpen option menu
DToggle date display modes
AToggle author display modes
GToggle revision graph
#Toggle line numbers
~Toggle line graphics
FToggle ref names
WToggle ignore whitespace
XToggle commit ID

See: Miscellaneous keys

m - Main view

ShortcutDescription
CCherry-pick selected commit
HGo to HEAD

See: View-specific actions

s - Status view

ShortcutDescription
uStage/unstage file or chunk
!Revert file or chunk
CCommit
MMerge with external tool

See: View-specific actions

c - Stage view

ShortcutDescription
uStage/unstage file or chunk
!Revert file or chunk
1Stage line
@Next diff chunk
[ ]Increase/decrease the diff context

See: View-specific actions

d - Diff view

ShortcutDescription
[ ]Increase/decrease the diff context

See: View-specific actions

y - Stash view

# ~/.tigrc
bind stash A !git stash apply %(stash)
bind stash P !git stash pop %(stash)
bind stash ! !git stash drop %(stash)

Tig already binds A/P/! to apply, pop, and drop with a confirmation prompt; these bindings skip that prompt.

See: bind command

0 Comments for this cheatsheet. Write yours!