Tig is a Ncurses-based and command-line Git repository browser. It supports various operating systems including Linux, macOS, and Windows. Tig provides an easier way to interact with Git and staging Git commits. It provides a rich set of features. Some of them are listed below:

  • Displays the list of stashes
  • Displays the changes for a single file
  • Allows to browse the commits in the current branch
  • Compares two branches
  • Displays the commits for one or more specific branches

In this post, we will show you how to install and use the Tig git repository browser on Ubuntu 20.04.

Step 1 – Install Tig

By default, Tig is included in the Ubuntu 20.04 default repository. You can install it using the following command:

apt-get install tig -y

Once the Tig is installed, verify the installed version of Tig with the following command:

tig --version

You should get the following output:

tig version 2.4.1
ncursesw version 6.2.20200212
readline version 8.0

You can see all options available with Tig using the following command:

tig --help

You should see the following output:

tig 2.4.1 

Usage: tig        [options] [revs] [--] [paths]
   or: tig log    [options] [revs] [--] [paths]
   or: tig show   [options] [revs] [--] [paths]
   or: tig blame  [options] [rev] [--] path
   or: tig grep   [options] [pattern]
   or: tig refs
   or: tig stash
   or: tig status
   or: tig <      [git command output]

Options:
  +       Select line  in the first view
  -v, --version   Show version and exit
  -h, --help      Show help message and exit

Step 2 – How to Use Tig

In order to work with Tig, you will need to clone any Git repository to your local system.

You can clone it using the following command:

git clone https://github.com/hitjethva/linuxbuz

Output:

Cloning into 'linuxbuz'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.

Once the repository is cloned, change the cloned repository using the following command:

cd linuxbuz

Next, run the Tig command without any argument and it will display the list of commits on the current branch:

tig

You should see the detailed information of your commits on the following screen:

Detail Information of Commits

To display all the references of your repository, run the following command:

tig refs

You should see the following screen:

References of repository

To display log activities of the above repository, run the following command:

tig log

You should see the following screen:

Log activity of repository

To display one or more objects such as commits and many more, run the following command:

tig show commits

You should see the following screen:

Display one or more objects

If you want to search for a particular pattern from your repository, run the following command:

tig grep linux

You should see the following screen:

Search specific pattern from the repository

To display the status of your git repository, run the following command:

tig status

You should see the following screen:

To display the status of the repository

To put Tig in Pager mode, run the following command:

git status | tig

You should see the following screen:

Put Tig in pager mode

To find out who made a change to a file, run the following command:

tig blame readme.md

You should see the following screen:

Display who made a changes in the file

Step 3 – Update Tig

If you want to update the Tig to the latest version, run the following command:

apt-get update -y
apt-get --only-upgrade install tig

Conclusion

In the above guide, you learned how to install and use Tig git repository browser on Ubuntu 20.04. You can now easily check and manage your Git repository from the command-line interface – try it today on your VPS hosting account!