QuickThought: Solving the unknown problem

Posted by Felix Geisendörfer, on May 19, 2008 - in Everything else » Quickies

Solving a known problem is great. Solving a problem nobody even knew they had until they see your solution is ingenious.

I'm playing around with git right now (while I really should be working on this). Besides doing a ton of cool stuff, it helps me with something I never even realized was a major PITA: The lack of cheap branches in svn.

A lot of times I'm working on a new feature for an application (and have a therefore unstable working copy) and suddenly a client / other developer wants me to fix some bug or look into an issue he has. Well normally I've done things as ridiculous as copy & pasting the contents of the files I modified in temporary files, reverted the changes and then checked out the problem only to quickly undo my revert minutes later.

With git this is what I do:

$ git commit -m "Interruptions suck less with git"
$ git checkout master
Switched to branch "master"
$ git checkout -b john.bug
Switched to a new branch "john.bug"
...
$ git checkout newfeature
Switched to branch "newfeature"

And voila I created a completely isolated branch called 'john.bug' based on the current repository master (trunk) branch without having to sacrifice my work in the 'newfeature' branch. Oh and the fact that I can do a million commits in any branch without them ever showing up in the master branch after merging with 'git merge --squash newfeature' is just amazing.

The best way to get started with git is to use it with your current subversion repository. I currently do all my work on the cakephp core using git, allowing me to do big refactorings in several (local) commits without anybody ever seeing them.