category Git

Git presentation at Purple Scout

On April 17, I was invited to do a presentation on Git for Purple Scout in Malmö, Sweden. Around 40 people showed up (including many XMMS2 folks) and endured 2-hours on what Git is, why it’s so awesome and all the fancy stuff you can do with it. I think people liked it and although most seemed to be using Git already, they were nice enough to say that they’d learned something anyway.

I’d given talks about Git previously in Switzerland, but for this occasion I reworked and pimped up my slides quite a bit to cover more material and have more cute diagrams. As before, you can get the slides for the Git presentation (PDF), or even fiddle with the source file, under the terms of the Creative Commons Attribution-Share Alike 2.5 License. Reuse, modify or poke fun at at will!

Sorry it’s still in proprietary Keynote format, because that’s the only vaguely acceptable software I found to make lots of diagram easily… Any Free alternative would be welcome, if someone knows of one.

It was great fun preparing and giving this course, and being back in Sweden and seeing friends again, so tusen tack till Purple Scout for making this happen!

Git Tips #1: Get there now

Sometimes you’ve played around in the history of a branch, edited some stuff in older commits, perhaps reordered them. You’ve reset’d back a few commits, and now you want to get to the final state you were at initially (or whatever state you want to get to).

Say you’ve kept a branch called “the-end-state” with the working end state you wanted to get back to before you started messing around with the history. You don’t want to merge (merging two alternative histories of the same development wouldn’t make any sense), you don’t want to rebase (it’s about building a new history, not forwarding it on top of the old one). You just want a new commit to bring you to “the-end-state“.

And you want to get there now!

The intuitive way to do this is the following:

$ git diff ..the-end-state > finish.patch
$ patch -p1 < finish.patch
$ git commit -a -s

But why three steps when you can do with just two, using git read-tree to import the tree from “the-end-state” branch into your index (-m to check for unmerged entries) and populate your work tree (-u):

$ git read-tree -m -u the-end-state
$ git commit -a -s

Thanks Junio for the tip on gitml!