34 C
Jaipur
Saturday, April 17, 2021

How to Install Tig on Ubuntu 20.04

Must read

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.

Features

  • 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:

tig

An interactive window appears, displaying each commit. The up and down arrow keys can help to navigate through them.

Main view of tig

To get details about a commit just select it, and hit Enter.

Details on a specific commit

To display commits from another branch, type:

tig updates

On the above command, the name of the branch is updates.

Commits for a specific branch

To find out the differences between two branches type:

tig updates..main

The above command compares two branches updates, and main.

Comparison of 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.

tig acting as unix-like grep utility

To show the references:

tig refs
References of the git repository

To display the list of stashes, type:

tig stash

To put tig in Pager mode, type:

git status | tig 
tig in Pager mode

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

Final thoughts

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.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article