Monades

Weekly Command: going over Git history with tig

April 18th, 2018 weekly-command xnix

There are many UI utilities that allow you to explore a Git repository, but for me, nothing beats tig.

A GIF showing examples of the usage of the tig command

The Basics

tig [view] [-options] [revs] 

tig is a text-based user interface for Git that can be used directly from your terminal to explore the repository in the current working directory. It can be invoked directly or by piping Git output.

Views

The program exposes different views, each view displays different data from the repository. You can tell tig to use a view with the optional view argument or you can switch views once tig is open with the default keybindings:

View Argument Keybinding
main view - m
diff view - d
log view log l
show view show -
blame view blame ** b *
grep view grep ** g
refs view refs r
status view status s
help --help h

* You need to have a file selected in the UI
** You neeed to supply an argument

If you are familiar with Git commands, view names are almost self-explanatory, I strongly encourage you to download tig and try the different views by yourself, they are very intuitive to navigate.

Pager mode

You can also pipe regular Git commands via stdin to tig, for example:

$ git show | tig

output of the git show command piped into tig

Resources



Subscribe

I try to post once a week interesting stuff about programming, *nix, and the web. If you’d like to be notified when a new post goes out, you can subscribe with the form below.


Roberto Dip