For those who find gitk less appealing, there’s an excellent alternative called tig. Early in my Git journey, I discovered this tool, which offers a command-line yet visual interface to Git. It’s available through package managers like MacPorts and Ubuntu’s apt-get (apt-get install tig).

Main View: Log and Diff

The simplest way to start with tig is by running the tig command in your Git repository. This brings up a visual git log. You can navigate through the log using the up and down arrow keys, or j and k if you’re familiar with Vim. Pressing on a log entry opens a split-pane window with the diff of that commit displayed. Use to move through the diff, and the arrow keys to move between commits. Pressing q closes the split-pane, and pressing q again exits tig.

Tree View

Another powerful feature of tig is the tree view. From the log view, pressing t switches to a navigable tree view of the repository. You can descend into directories or view files by pressing , and view an annotated version of a file by pressing -B.

Working with Branches

While we’ve been using tig on the currently checked-out branch, tig also accepts a revision argument (branch, tag, hash, etc.). This is particularly useful for inspecting remote branches. For instance, running tig origin/rel-1.5 lets you see the status of the remote branch.

Viewing another branch while in a different branch is also handy for cherry-picking changes. For example, to cherry-pick a change from master to the release branch origin/rel-1.5, you can:

Check out the release branch with git checkout -b 1.5 origin/rel-1.5.
Open tig using tig master.
Navigate to the desired changeset and press <shift>-C to cherry-pick the change.

Blame View

I frequently use the tig blame command to investigate file histories. Running tig blame [file] provides a detailed, annotated view of the file, showing who last modified each line.

Tig offers a robust set of features for interacting with Git repositories visually from the command line. While the log and tree views are particularly useful, there are many other features to explore, like tig show [rev] and tig blame [file]. If you have additional tips or ways to utilize tig effectively, feel free to share in the comments!