Thursday, 29 April 2010

git lola

The best tip I learned at Scott Chacon's talk at linux.conf.au 2010, Git Wrangling - Advanced Tips and Tricks was this alias:

        lol = log --graph --decorate --pretty=oneline --abbrev-commit

This provides a really nice graph of your tree, showing the branch structure of merges etc. Of course there are really nice GUI tools for showing such graphs, but the advantage of git lol is that it works on a console or over ssh, so it is useful for remote development, or native development on an embedded board.

It is even nicer when you turn syntax coloring on in git, which also has the advantage of colorizing diff output to warn about bad whitespace.

To get an idea of a whole project structure, I found myself often running git lol --all, where the --all option says to show all branches. I used that often enough that I made a new alias, git lola:

        lola = log --graph --decorate --pretty=oneline --abbrev-commit --all

which has the added bonus of making me hum Lola every single day.

So, just copy the following into ~/.gitconfig for your full color git lola action:

[alias]
        lol = log --graph --decorate --pretty=oneline --abbrev-commit
        lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
[color]
        branch = auto
        diff = auto
        interactive = auto
        status = auto

5 comments:

  1. Nice tip - thanks! I've been relying on 'gitk' for that, but the GUI just slows me down.
    ReplyDelete
  2. My cute alias for this command: "git k". :^)
    ReplyDelete
  3. Cool tip. But have you tried tig? It's a ncurses interface to git and graphs the history when 'g' is pressed.
    ReplyDelete
  4. I think you can replace your entire [color] section with a much simpler "ui = true":

    [color]
    ui = true

    (with proper indentation of course)
    ReplyDelete
  5. Very neat! I didn't know the alias section - it will be saving my life!

    And thank you very much for putting that song in my head ;-)

    ♩ ♪ ♩ Lo-lo-lo-lo-looooo-laaa! ♩ ♪
    ReplyDelete