Git Like a Pro: Harnessing the Tig Command-Line Interface

Patrick Daether

Patrick Daether

March 04, 2024 · 4 min read

Do you ever feel like you're wrestling an octopus every time you try to manage your Git repositories from the command line? Enter Tig, the unsung hero of Git interfaces that promises to turn your command line woes into a graceful dance of version control mastery.

Yeah, to do a git status or git commit on the command line, you don't need an extra program. Merge and rebase aren't a big deal for the old hands either. And if you ever need an overview of all local and remote branches in that big project, almost every modern IDE offers a corresponding git UI either natively or via a plugin. And then there are standalone apps like Git Tower or SourceTree.

So, why an additional tool for the command line?

Personally, I like sticking to the command line and using the mouse less, which many Git UIs require. And sure, you can get creative with git log --graph on the command line, but what's still missing is the ability to interact with that graph.

# Yes this kinda looks nice, but still misses the interactivity...
git log --oneline --graph --decorate --all

Enter tig. Let's dive into the key features of tig.

Installation

As expected, installation is just a one-liner on all major systems.

Basic Usage

After simply calling tig in the command line, you get a good overview of the branches and commits, and you can navigate up and down with the arrow keys. Pressing Enter opens up a further vertical view containing details about the selected commit. Here, you can navigate with k and j or close the view with q.

Searching in tig works similarly to many other Linux tools. Use / for forward search and ? for backward search.

If you just want a list of commits without the graphical representation of branches, you can call tig log.

Tig: Git log with commit details.

Since tig is essentially just a wrapper for git log, you can use the same arguments. For example, if you only want the history of a file, simply type: tig log path/to/my/file.txt

Within tig, you can switch between different views using keyboard shortcuts. For example, press m for the main view and l for the log view. Pressing h lists all keyboard shortcuts clearly.

Git Status View

With tig status, you get the interactive version of git status. Here, you can see all staged and untracked files, including details, and edit the status.

Moreover, Tig also offers interactive versions of git blame or git grep. For these and other commands, functions, and possible customizations, I recommend taking a look at the Tig docs: https://jonas.github.io/tig/

In general, tig is an underdog and unfairly little known. I wouldn't want to miss it in my daily work with git anymore.

Similiar Posts

Patrick Daether
Patrick Daether

March 18, 2024

5 min read
Patrick Daether
Patrick Daether

March 08, 2024

4 min read

Copyright © 2024 Patrick Daether. All rights reserved.