Tig is a text-mode interface for git. It mainly serves as a Git repository browser. Written as a ncurses-based text-interface, it can also assist in staging changes for commit at the chunk level. When the input is provided via the stdin, tig enters the Pager mode. Tig works on Linux, macOS, and Windows.
In this tutorial, we learn how to install Tig on Ubuntu 20.04.
- Browses the commits in the current branch
- Displays the commits for one or more specific branches
- Compares two branches
- Helps to see the changes for a single file
- Displays the list of stashes
- Shows references for branches, tags and remotes
Install tig on Ubuntu
First update the system, run:
sudo apt update
To install tig on ubuntu, run:
sudo apt install tig
How to use tig
The tig utility is very straightforward. To display the list of commits on the current branch, type:
An interactive window appears, displaying each commit. The up and down arrow keys can help to navigate through them.
To get details about a commit just select it, and hit Enter.
To display commits from another branch, type:
On the above command, the name of the branch is
To find out the differences between two branches type:
The above command compares two branches
To display changes for a single file, type:
tig -- README
In this case, the file is README.
To display revisions between two dates for a specific file, type:
tig --after="2021-01-01" --before="2021-01-17" README
To use tig as a unix-like grep utility, type:
tig grep -p Beginner
After the -p flag, the text you want to look for should be placed. In this case, the command is searching the entire repository for files which contain the word Beginner.
To show the references:
To display the list of stashes, type:
tig in Pager mode, type:
git status | tig
The above command pipes the output as stdin to tig.
How to update tig
To update the official repository type:
sudo apt update
To upgrade tig to the latest version, type:
sudo apt get --only-upgrade install tig
How to uninstall tig
To completely remove tig from your Ubuntu machine, type:
sudo apt remove tig -y
Through this article you learned how to use tig through some practical and easy to follow examples. Perfectly fit as a browser for your git repository, it is a very useful tool when it comes to information gathering on code commits.