Using Tig: A Text Interface for Git

I am a command-line junkie. It seems to be a common trend among Linux users such as myself, preferring a terminal to any type of GUI. When I am working with Git I perform everything from the command-line. But I also use Tig as a text-based interface to Git, which I will introduce to you today.

Tig as a Pager

You can perform a lot with Tig by simply starting the program in a Git repository, which I will explain later. Tig can also serve as a pager. In other words, you can get highlighted, navigable output by piping a Git command into Tig. Here are some examples:

  • git branch -a | tig The Git command shows all of the branches in a repository. When we pipe that output into Tig we get the same list. But it is interactive. For example, pressing the l key on a branch will show you its log.

  • git show | tig With this command Tig will produce output that looks like the plain git show, albeit with more colors. The useful aspect is the same as that mentioned above: it allows you to interactively navigate the repository without having to quit Tig.

Views

Running Tig by itself will present the ‘main view’. This is a list of all of the commits. It shows the date of the commit, the author, which commits are currently the base of branches. And to save space it only shows the first line of each commit. This is a good reason why Git commit messages should begin with a single line followed by a blank line and then any further important information. A number of Git tools rely on that format and Tig is no exception.

The log and diff views display interactive information similar to what you would see from git log and git diff respectively. If you press the h key for ‘help’ you will see that Tig provides a number of other views that allow you to see all branches, the changes staged on the index that are ready to commit, individual trees and blobs for commits and more.

Actions

Tig is more than a repository browser. It lets you update the index with the u key, which is the same as running git add on that file. If you have a merge conflict the M key will launch git mergetool. And there are additional commands for checking out files, committing chunks of data instead of the entire file, searching commits for text and changes, ignoring whitespace in diffs, and even enabling a graphics mode to help visualize branches.

Conclusion

If you use Git and have a deep attachment to using a terminal then you should try using Tig. Even though I’ve loved GNU Emacs for nearly two decades I still prefer to use Tig rather than Emacs’ built in version control commands. Tig simply feels faster and snappier, and gives me the impression that I can browse and modify my repositories with ease.

I must admit, however, that I have no benchmarks to prove that using Tig is more productive than Emacs’ version control commands. I use Tig out of personal preference because I like to keep my Git commands in my terminal. I honestly don’t know why. It must be habit.

If you’re a fellow Git terminal addict then give Tig a little bit of your time. Even if you do not prefer to use its commands it still makes for a nice pager.

Advertisements

2 thoughts on “Using Tig: A Text Interface for Git

Add Your Thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s