Back to Cheatsheets

Tig

Git2022-12-08

Installing

# MacOS + Homebrew
$ brew install tig --HEAD
# Ubuntu
$ sudo apt install tig

Invocation

CommandDescription
tigLogs
------
tig statusStatus
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)

You can substitute git logtig.

Shortcut keys

{: .-three-column}

Switching views

ShortcutDescription
mMain view
dDiff
tTree (files)
bBlame
sStatus
cStage
yStash
gGrep
hHelp
{: .-shortcuts}

All views

ShortcutDescription
<enter>Enter and open selected line
<Back to previous view state
<tab>Move focus to next view
RRefresh
qClose view
QClose all (quit)
,Parent commit
{: .-shortcuts}

Cursor navigation

ShortcutDescription
/Search
?Search backwards
j kUp/down
J KNext/previous
<space>Page down
-Page up
^DHalf page down
^UHalf page up
{: .-shortcuts}

Option toggles

ShortcutDescription
IToggle sort order modes
iChange sort header
DToggle date display modes
AToggle author display modes
#Toggle line numbers
~Toggle line graphics
FToggle file names
WToggle ignore space
{: .-shortcuts}

m - Main view

ShortcutDescription
XToggle commit sha
CCherry pick a commit
{: .-shortcuts}

s - Status view

ShortcutDescription
uStage/unstage file or chunk
!Revert file or chunk
CCommit
MMerge with external tool
{: .-shortcuts}

c - Stage view

ShortcutDescription
uStage/unstage file or chunk
!Revert file or chunk
1Stage line
\Split current diff hunk
[ ]Increase/decrease the diff context
{: .-shortcuts}

d - Diff view

ShortcutDescription
[ ]Increase/decrease the diff context
{: .-shortcuts}

y - Stash view

ShortcutDescription
AApply selected stash
PPop selected stash
!Drop selected stash
{: .-shortcuts}