Throwaway code under source control? To many Subversion users this may sound a bit OTT. But here are a few things that you need to consider about throwaway code:
- It frequently needs to be debugged;
- It frequently needs to be diffed;
- It frequently needs to be rolled back to an earlier state;
- It frequently needs short experimental spikes to try out alternative approaches;
- It frequently needs to be bisected;
- It frequently needs to be re-used;
- It frequently turns out not to be as throwaway as you expected.
In other words, even for throwaway code, source control still has a lot to offer. And Git makes it so lightweight and seamless that within a few weeks, you find yourself doing exactly that. All you have to do is:
- Type git init
- Drop in a standard, peer reviewed .gitignore file
- Type git add -A && git commit
By contrast, just getting code under source control in Subversion in the first place is a cumbersome, heavyweight process. Subversion can not create a versioned working copy for existing code in-place in a single step. To get your code under source control, you have to:
- Set up a suitable repository if you haven’t already done so
- Allocate an appropriate folder in said repository
- Create a branches/tags/trunk structure
- People often skip this step, only to regret it later.
- Import your code into said repository
- Painstakingly ignore everything you don’t want to check in
- One folder at a time, often getting it wrong.
- One folder at a time, often getting it wrong.
- Check out your code into a new, empty folder
- Replace your old folder with the new one
- On Windows, close down command prompts, text editors, and all sorts of other mystery processes that have opened up file locks on your original code for no apparent reason and try again.
Because the bar is much higher, Subversion users almost never put throwaway code under source control. In fact, they often fail to put not-so-throwaway code under source control either. It is very common for Subversion shops to have code running in production for paying clients that is not under source control anywhere.
