I’m a big fan of Git, but I’m not such a big fan of most UIs for it, especially the ones integrated into IDEs. I find them convoluted and confusing. They try to map some generic “VCS” language onto the commands, or try to hide too much, making it hard to understand what’s going on. Or worse: they’re written in Tcl/Tk…

In short, I don’t trust ’em.

So command line it is for me, which is fine because I love my command line. Except once in a while, it’s nice to be able to see a “graphical” view of your history, or to have a bit of help when preparing your commits.

Enter tig. tig is a text-mode, ncurses-based UI for git written by Jonas Fonseca. In short, it is the mutt to your Outlook, the Vim to your Emacs, the w3m to your Firefox. I use it all the time, but I haven’t seen many people using it so I thought I’d publicize it a bit. So, why is it awesome?

It’s insanely fast

Seriously. Three letters to type, and it instantly shows up. No fussing around with your mouse, or alt-tabbing to another window, or waiting for a JVM to start. It’s there at your fingertips whenever you need it. It literally loads the 50,000 commits of the Jira codebase in a fraction of a second.

History view

The default view when launching tig is the history view. It’s basically a git log, with a bit of ASCII-art to represent the history (you can hide the graph with g). Without any argument, it displays the current branch. You can also pass it the name of a branch, or --all for all branches. You can also pass it a range of commits as git log would expect (e.g. tig master..branch). You can navigate through the commits with arrow keys or j/k. Use the / key to search (match is done on summary or author).

Pressing Enter on a commit opens that commit in a split diff view.


You can then navigate in the diff view using the j/k keys. At the beginning of the diff is the list of files that the commit touched. If you select one of them and press Enter, you will directly jump to the beginning of that file in the diff. Press q to close the diff view (and press q a second time to quit tig).

If you press t on a commit in the history view, you will open the tree view. In this view, you browse the content of your repository in exactly the state it was at that point in time (just use the arrow keys and Enter), without having to do a git checkout.

Status view

The is the killer feature in my opinion, and the one I use the most. If you start it with tig status, or if you press shift-S in the main view, you will go to the status view. This is like git status, but interactive. You can see the files that you’ve modified and staged, the files you’ve modified but haven’t staged yet, and the files that are no yet tracked by git. If you select a file that is not staged or untracked and press u, it will stage it. If you select a staged file and press u, it will unstage it. No need to remember that pesky git reset HEAD <file> command. You can also press ! on a file to revert all uncommitted changes to that file.

If you press Enter on a file, you will see a diff view of the changes you’ve made to that file (press q to close that view), making it easy to review what you want to commit or not. Even better: you can navigate in the diff with the j/k keys (line by line), or the @ key (chunk by chunk). If you then press u it will only stage the current diff chunk (a section in the diff that starts with @@). You can also stage a single line with 1. It’s all the power of git add -i, except easy to use.

When you are ready to commit,  press shift-C. and it will open your favourite editor to enter the commit message (make sure you close any open diff view first).


Blame view

Want to know who messed up your beautiful code or introduced that nasty bug? Just do tig blame <file>. It is similar to git blame or Git -> Annotate in IDEA. Just select a line and press Enter, and it will show you the last commit that touched that line.


Pager mode

Got a fancy git log command that you’ve tweaked to display just the information you want? Just pipe its output into tig to have it nicely colorised, and easy to scroll back and forth. Also, if you’re on a line that contains a commit hash, you can just press enter to view that commit. This should work for most Git commands.

How do I get it?

If you use OS X, you can easily install it via homebrew, and most Linux distributions should have a package for it. If not, you can always get the source from http://jonas.nitro.dk/tig/ and compile it yourself. I think it is even available for Cygwin, so there’s no reason not to try it!

Don’t hesitate to look at the man page, or press h inside tig: There’s a lot more you can do with it.

Check out more Git goodies from Atlassian:
Git blogs on developer.atlassian.com
Getting Git Right

git? tig!