While I really enjoy
qgit for visualizing history, it is a graphical client. Sometimes you’re on a remote machine or want to look at a very complicated set of commits. In those cases,
git show-branch might not be enough. Enter tig.
Tig is best described as a graphical history viewer in ncurses. It lets you view history using the same syntax as git log, qgit, and gitk (anything supported by
git rev-parse). Running
tig in a git repository will open it in “main view”. The lines in main view look very similar to the output of
git log --pretty=oneline --abbrev-commit.
tig has a few command line options:
All of these options act the same as their git counterparts, except they show in its coloured pager.
tig is running, you can get help by pressing ‘h’. tig’s views consist of main, diff, log, tree, blob, blame, pager, status, and stage. Most of these views are fairly simple and I’ll leave their use as an exercise for the reader.
Pressing ‘g’ in main view shows the revision graph:
This is what makes
tig as useful as other visualization tools like qgit or gitk.
Pressing ‘enter’ on any of the commits in main view splits the window and shows the diff below. Vi’s ‘j’ and ‘k’ keys move the diff up and down.
tig blame can be more useful than a regular
git blame because you can press ‘enter’ and view the diff that made the change to that line.
tig doesn’t support some option that works with git, you can still use
tig to page git’s output by piping git’s output into tig. It will still colour all the items it understands, detect commit hashes, and display diffs.
tig can be really helpful when doing development on a remote machine that doesn’t have vnc or any X tools installed.