Visualizing Your Git Repository

About half of my interactions with Git take place on the command line. But when I want to understand what's going on, I use a visual Git tool. On the Mac, the best thing I've found is GitX. On other systems, gitk should be available; you can search the web to find something that works for you.

The main point of using a visualizer is to help you make sense of your branch history. For example, to list all commits in your repository at the command line, you could do git log --oneline --abbrev-commit --all—which will get you this flattened view:

(Thanks to @cflipse at work for pointing out that --pretty=oneline --branches= could be shortened to --oneline --all!)*

Clear as mud, right?

Or, you can add --graph to that command, which will show you a slightly more useful view:

git log --oneline --abbrev-commit --all --graph

Much better!

(Thanks to @mjdominus and @JRGarcia for reminding me about the --graph option!)

If you want to see branch and tag labels, add --decorate:

git log --oneline --abbrev-commit --all --graph --decorate

I'm going to need a wider design template if this goes on...

(Thanks again to @JRGarcia for the --decorate tip!)

You can also add --color to pretty up the display a bit more (sorry, no time to take a screenshot as I add this):

git log --oneline --abbrev-commit --all --graph --decorate --color

And, in fact, I have a shell alias that does all of this:

alias gg='git log --oneline --abbrev-commit --all --graph --decorate --color'

But mostly, I just use GitX, which shows all of the same information in a cleaner graphical view:

I like the purdy colors.