Skip to content

More stuff that you need: tig
“Control board” by Ben Townsend (CC BY 2.0)

We all know it: the git command line tool is extremly powerful, and chances are that you will not need any other tool for doing the job. However, it is true that performing some tasks, like navigating the repository history, is more intuitive using software such as Gitkraken or even gitk.

Instead of selling your soul and embracing unholy tools like those, it is possible to use tig, a command line tool based on ncurses (so it is not simply text-based, including quasi-graphical elements).

In some sense is like cheating, but not too much, although it depends on your level of command-line-purity.

As always, let’s skip the installation and directly take a look at the juicy aspects of tig. Here is how to incorporate it into your workflow in three convenient actions.

Note: the examples are applied to the git repository of colout, a tool about which I will probably talk about in future posts.

Browse repository history

If you simply type tig,you will see the branch tree of the repository. The output is colored by default, so no fancy alias
is required, making it is easy to identify commiters, tags, the usual stuff. Once you are in this
main view, you can check the contents of each commit by pressing ‘Enter’. The view then splits and
the changes introduced by the comments are shown (diff view).

To navigate through the newly opened window, vim-style keys can and must be used. Consequently, you can make use of your old friends ‘/’ to search, and ‘k’ and ‘j’ to go up and down, among others (in order to check all available commands, press ‘h’).

In order to close this split view, simply press ‘q’. If instead of an split you prefer to have a full screen view of the diff, you can press ‘d’ and use the same navigation keys.

tig default
Default view of tig. All the info you need is presented: date, commiter, branches, merges and commit messages.

Stage/unstage changes

When typing tig status, an interactive view of the status of the repository will be shown. This is very helpful for manually
selecting which files will go into the commit. To do so, simply highlight the desired files using the navigation keys (remember, vim-style or simply arrow keys) and press on ‘u’, and the file will be staged. This works in both directions, so if you wish to unstage a file, ‘u’ can be used too.

Once you are finished, press ‘q’ to exit the interactive view. It is not necessary to apply the changes, the files will be staged/unstaged as you indicated.

One of the advantages of this approach, besides its ease of use, is that the diff view is accessible. Therefore, you can check the changes present in a file by pressing ‘d’, allowing you to decide whether to commit that file or not based on its modifications.

tig status
tig status. A very handy way of preparing your commits.

Navigate the log

This is the feature that I probably use the least, but it can be helpful nonetheless. tig log provides an improved version of git log, more colorful and with access with the aforementioned views, including the diff view.

tig log
tig log. Being able to analyze the changes applied by a series of commits can be helpful to find the culprit.


Use tig. Just that.

Have a nice weekend.



Published inTools

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *