Is Tig Better Than GitKraken? Browse Repositories on the Terminal | by Mirco on Tech | Sep, 2022

Leverage the power of the command line to browse your repositories

Screenshot of tig in action
image by Ryan Bergman

Tools like SourceTree and GitKraken are popular among many developers. They visualize the commit tree and make it easy to find differences between commits. This makes browsing a repository comfortable.

You can’t use those tools in the terminal. Once you connect to a remote server, you lose all the advantages. Also, SourceTree and other desktop clients are optimized for the mouse — and we use the keyboard faster.

We can solve this with tig, the command line repository browser.

You can install tig directly with the package manager on all common Linux distributions. I used apt on Ubuntu to install it.

sudo apt install tig

Mac users can use homebrew:

brew install tig

Windows users should use Git for Windows. It comes with tig already installed.

You can install directly from the sources if you want to use the latest version. Detailed instruction is available on tig’s website.

Once you installed tig, go to a directory that contains a git repository and run tig from the command line:

The main view with commit details on the bottom pane.

It shows you a list of all commits similar to git log --oneline. Use the arrow keys to navigate the list. If you press Enter, tig shows you the details of this commit. You can press q to go back to the list. Pressing q from the list will close tig.

Tig has multiple views. The commit list is called the main view. You can always go back to the main view by pressing m. Information about a commit (as seen in the bottom pane above) is shown in the diff view. You can open a full-screen diff view of the selected commit by pressing d.

Switching between main and diff view by pressing m or d.

All in all, the controls of tig are similar to vim or less. Entering a slash will start the search in the current view:

1*YhrlBDcdg8g6DD H2U aiA
Searching in the main and diff view.

As you can see, tig offers many ways to view and search your repository. But that was just a small sample of what tig can do. You can view all features and hotkeys by pressing h.

1*Y3aVjbLxpjuY5l IchBhzw
tig keybindings

Tig offers a lot of configuration options. Create a file named .tigrc under your home directory. The syntax for adding settings is:

set   variable = value

For example, with the following configuration tig will show 25 lines before and after each diff:

set diff-context = 25

In my mind, tig comes with sensible defaults. However, if you dislike something, you can change it with the settings as there are plenty of them.

You can find all configuration options on tig’s website as well.

Tig is an outstanding repository browser for the command line. I think tig outperforms SourceTree and GitKraken since you can control it easily and fast with your keyboard. If you are already familiar with vim or less, you will quickly feel at home.

Give tig a try!

Useful links mentioned in the article:

News Credit

%d bloggers like this: