• Playing the Blame Game

    schacon 18 Nov 2008

    One of the features I use a lot in git is ‘git blame’, which will
    show you who was the last person to change each line in any file
    in your project, and which commit it was.

    This is most often used by me to avoid embarassment, as I have a
    ridiculously short term memory – there have been several dozen
    times in the last few years where I think “What moron added this code?
    It looks as if a slow monkey on barbituates got arbitrarily angry at the
    keyboard!”, only to find through my friend ‘git blame’ that that monkey
    was me. That’s helpful information to know before you go yelling at
    your co-workers.

    So, we thought adding this face-saving functionality to GitHub might
    be a good idea. Enter the ‘blame’ link:

    If you click that link from the file view of any of the files in a
    project, you’ll get something that looks thusly:

    It’s basically the same view, with the code itself a bit truncated
    and a bunch of fun new information added. For each block of code that
    changed at once, it will show you the sha of the commit that last
    changed it, along with the author, date and message of that commit.

    Even cooler, it will show a little " » " icon next to the sha – if
    you click this it will ‘drill down’ to show you the blame for the file
    from that commit instead. Meaning, if you wanted to know who changed that
    line before that gal, clicking on that icon will show you the
    next previous person, and so on. If that doens’t make sense, just give
    it a try – you can do this on any file in any of your projects. Go nuts!

    (don’t really go nuts…)

  • Comments

    topfunky Tue Nov 18 08:02:26 -0800 2008

    Will premium accounts provide the ability to shift the blame to another developer? I would pay for that!

    ryanb Tue Nov 18 09:12:45 -0800 2008

    THANK YOU! I’m so glad to see this feature. This is a brilliant way to better understand code as you’re reading it.

    Not sure what the developer’s intention was at a given line of code? Play the blame game and see the commit message. Even better: click the SHA to see what else they changed at that same time.

    the-kenny Tue Nov 18 09:28:45 -0800 2008

    It looks like it’s broken here: http://www.abload.de/img/bild3pt5p.png

    dustin Tue Nov 18 11:02:21 -0800 2008

    A couple of nights ago I spent hours rewriting the memcached history to make sure all of the authors were recognized appropriately. This is timed quite well. It’s a bit painful for firefox to load this page, though:

    http://github.com/dustin/memcached/blame/rewritten-bin%2Fmemcached.c

    mlangenberg Tue Nov 18 13:04:51 -0800 2008

    I really like this feature! Using ‘git blame’ is really powerful.

    Please log in to comment.