dotlinux blog

Tig – A Command Line Browser for Git Repositories

In the world of version control, Git has become the de facto standard. While there are many graphical user interfaces (GUIs) available for Git, sometimes working directly from the command line offers more flexibility and efficiency. Enter Tig, a powerful command line browser for Git repositories. Tig allows you to explore and interact with your Git repository in a text-based interface, providing features similar to a GUI but with the speed and simplicity of the command line. In this blog post, we'll take a deep dive into Tig, exploring its features, installation process, and how to use it effectively.

2026-05

Table of Contents#

Features of Tig#

Tig offers a wide range of features that make it a valuable tool for working with Git repositories. Some of its key features include:

  • Commit Browsing: Easily navigate through the commit history of your repository, view commit messages, and inspect the changes made in each commit.
  • Branch Viewing: View branch information and commits directly within the interface.
  • Diff Viewing: Compare the differences between commits, branches, or files using a clear and intuitive interface.
  • External Git Commands: Use keyboard shortcuts to invoke external git commands for branch and merge operations.
  • Searching: Search for specific commits, files, or text within your repository using powerful search capabilities.
  • Customization: Tig allows you to customize its appearance and behavior to suit your preferences.

Installation#

The installation process for Tig varies depending on your operating system. Here are the steps for installing Tig on some popular operating systems:

Linux#

  • Debian/Ubuntu:
sudo apt-get install tig
  • Fedora:
sudo dnf install tig
  • Arch Linux:
sudo pacman -S tig

macOS#

  • Using Homebrew:
brew install tig

Windows#

  • Using Chocolatey:
choco install tig

Basic Usage#

Once Tig is installed, you can start using it by navigating to your Git repository in the terminal and running the tig command. This will open the Tig interface, which consists of several windows:

  • The main window: Displays the commit history of your repository.
  • The status window: Shows the current status of your repository, including any uncommitted changes or untracked files.
  • The help window: Provides information about the available commands and shortcuts in Tig.

You can use the arrow keys to navigate through the different windows and the commits in the main window. Pressing the Enter key will open the selected commit in a new window, allowing you to view the details of the commit, including the commit message, author, and date.

Commands and Shortcuts#

Tig provides a number of commands and shortcuts that you can use to interact with your repository. Here are some of the most commonly used commands:

  • q: Quit Tig.
  • j/k: Move up/down in the main window.
  • Enter: Open the selected commit.
  • d: View the diff for the selected commit.
  • b: Toggle the branch view to see all branches and their commits.
  • s: Open the search window to search for commits, files, or text.

One of the most useful features of Tig is its ability to browse through the commit history of your repository. The main window displays a list of commits, with the most recent commit at the top. You can use the arrow keys to navigate through the commits and the Enter key to open a commit and view its details.

Commit Details#

When you open a commit, Tig displays the following information:

  • Commit message: The message that was entered when the commit was made.
  • Author: The name and email address of the person who made the commit.
  • Date: The date and time when the commit was made.
  • Tree: A list of the files that were changed in the commit.

You can use the arrow keys to navigate through the files in the tree and the Enter key to open a file and view its contents.

Viewing Diffs#

Another important feature of Tig is its ability to view the differences between commits, branches, or files. You can use the d command to view the diff for the selected commit, or you can use the diff command to compare two commits or branches.

Diff View#

When you view a diff, Tig displays the following information:

  • Old version: The contents of the file before the changes were made.
  • New version: The contents of the file after the changes were made.
  • Line numbers: The line numbers in the old and new versions of the file.
  • Hunks: The sections of the file that were changed.

You can use the arrow keys to navigate through the diff and the Enter key to open a hunk and view its details.

Branching Operations#

Tig provides viewing capabilities for branches and can invoke external git commands for branch operations. You can use the b key to toggle the branch view, which displays all branches and their commits. From this view, you can see branch structure and navigate between branches. To perform actual branch operations such as creating, switching, or merging branches, Tig invokes the corresponding git commands externally.

Searching#

Tig provides a powerful search feature that allows you to search for specific commits, files, or text within your repository. You can use the s command to open the search window and enter your search query.

Search Options#

Tig provides a number of search options that you can use to refine your search. Here are some of the most commonly used search options:

  • -c: Search for commits.
  • -f: Search for files.
  • -t: Search for text.
  • -r: Search recursively.

Search Results#

When you perform a search, Tig displays the search results in the main window. You can use the arrow keys to navigate through the search results and the Enter key to open a result and view its details.

Customization#

Tig allows you to customize its appearance and behavior to suit your preferences. You can use the ~/.tigrc file to configure Tig. Here are some of the most commonly used configuration options:

  • color: Enable or disable color in the Tig interface.
  • pager: Specify the pager program to use for viewing diffs and other output.
  • editor: Specify the text editor to use for editing commit messages and other text.

Example .tigrc File#

Here is an example .tigrc file that enables color and sets the pager to less:

color = auto
pager = less -R

Conclusion#

Tig is a powerful command line browser for Git repositories that provides a number of features and commands for working with Git. Whether you're a seasoned Git user or just getting started, Tig can help you manage your repositories more efficiently and effectively. With its intuitive interface and powerful features, Tig is definitely worth checking out.

References#