Here’s a quick and fascinating tip for today: using git log --graph. If you’re ever puzzled about the direction of branches or how merges were executed, and you’re feeling a bit too lazy to open up tools like gitk, gitx, or the GitHub Network Graph, fear not! You can get a simple and quick graphical representation of your commits right from the command line.

Executing git log --graph produces a graph representation of commits in my clone of the Jekyll repository, which includes changes not yet pushed from yesterday’s post on merging and branching. However, in its default form, it might not be as helpful as we’d like.

Let’s refine that output a bit by using git log --graph --pretty=oneline --abbrev-commit to compress commits and display only the first 7 characters of the SHA1:

Ah, much better! And remember, there are plenty of other ways to visualize your repository as well.

UPDATE: This command is available in Git versions 1.5.6 and newer.