I love staring at branches and shuffle, reorder and squash commits

I don’t know what it is. Maybe it’s inherent to human nature to strive for and to create order. Maybe it’s just me.

But I love staring at branches and I love cleaning up my commit history until it shines. This is of course possible and encouraged with git and it’s only possible if you haven’t shared your code with anyone else publicly (pushed to a shared remote repository). So how does a shuffling cleaning frenzy look like? Here: (The screen-shot below is from GitX just for eye candy).

How do I work? Before I share my work with other developers I commit stuff to local branches furiously and in very small increments, I branch away like crazy. Then after a while I realize things are messy and commits are not elegantly divided per feature. So I stop coding and start cleaning the history of commits until they fit into a clean list of recognizable units of work. At that point I can merge the work back into the mainline, say the master branch or some shared topic branch.

Tools of the trade ? git branch, git reset, git cherry-pick and the very powerful git commit –interactive.

If you’re wondering why I like git and why I don’t use x (where x could be svn, hg, bzr or perforce) a good collection of reasons can be found at Why Git is Better Than X .

2 Responses to “I love staring at branches and shuffle, reorder and squash commits”
  1. Pedro 17 August 2009 at 6:44 pm #

    Ok, let me be the Devil’s advocate here. That page’s comparison of Git and Mercurial does not provide enough motivation for preferring one over the other, IMHO.

    1. Cheap local branching: Mercurial does this. And I’ve never had problems with speed.
    2. Staging area: Never had any good use for it. My workflow usually is add->commit immediately.
    3. GitHub: Really? Is this a motivation, with today’s cheap servers available all over the web?

    Besides all of this, Mercurial was chosen by Guido Van Rossum for storing the python source code. Being a python lover yourself you should know better than piss off the BDFL of python like that ;)

  2. nick 17 August 2009 at 7:27 pm #

    The staging area is quite powerful, once you start using it. git commit –interactive I mentioned above is an example of a use for it. Splitting in-file hunks into separate commits is wonderful. Try it!

    Github is a real motivation, trust me. It’s a totally new way of interacting and coding together. It’s not about servers and free hosting. It’s about workflow and network with your peer developers. It’s very valuable in my opinion.

    I salute and I am happy that the Python team chose a DVCS, whichever it might be. It’s a good thing(tm). And I read the whole PEP and discussions on why in the end they did go with mercurial. It makes perfect sense for them.

    git and hg are both tremendous efforts and are revolutionizing software development.

    It’s just that my fingers and brain is wrapped around git for now. And I love it.