Friday, January 09, 2009

Do I really need version control?

A user recently asked:
I read all over the internet (various sites and blogs) about version control. How great it is and how all developer NEED to use it because is a god bless.

Here is the question: do I really need this? ... I usually work alone (freelancer) and I had no client that asked me to use svn (but never is too late for this, right?). So, should I start and struggle to learn to use svn (or something similar?) Or it's just a waste of time?
Here's a scenario that may illustrate the usefulness of source control even if you work alone.
Your client asks you to implement an ambitious modification to the website. It'll take you a couple of weeks, and involve edits to many pages. You get to work.
You're 50% done with this task when the client calls and tells you to drop what you're doing to make an urgent but more minor change to the site. You're not done with the larger task, so it's not ready to go live, and the client can't wait for the smaller change. But he also wants the minor change to be merged into your work for the larger change.
Maybe you are working on the large task in a separate folder containing a copy of the website. Now you have to figure out how to do the minor change in a way that can be deployed quickly. You work furiously and get it done. The client calls back with further refinement requests. You do this too and deploy it. All is well.
Now you have to merge it into the work in progress for the major change. What did you change for the urgent work? You were working too fast to keep notes. And you can't just diff the two directories easily now that both have changes relative to the baseline you started from.
The above scenario shows that source control can be a great tool, even if you work solo. Source control can solve many problems for you, such as the following:
  • You can use branches to work on longer-term tasks and then merge the branch back into the main line when it's done.
  • You can compare whole sets of files to other branches or to past revisions to see what's different.
  • You can track work over time (which is great for reporting and invoicing by the way).
  • You can recover any revision of any file based on date or on a milestone that you defined.
For solo work, Subversion is recommended. CVS is all but antiquated, and GIT is more useful for distributed teams. A good book is Pragmatic Version Control Using Git by Travis Swicegood.

I'm posting to my blog the questions I've answered on StackOverflow, which earned the "Good Answer" badge. This was my answer to "Do I really need version control?"


Jani said...

That's a really good example of why you might need SVN. I just tend to tell people that it saves you the trouble if you ever need to revert things =)

ps. would be nice if I didn't have to login to comment..

Bill Karwin said...

@Jani: Thanks, being able to revert easily and to any revision is a good advantage of version control too.

I've found, however, that people who don't use version control can work around this simply by cloning their source tree. They literally keep directories like "src_aug", "src_sep", "src_oct", "src_nov" lying around on their disk.

Using a scenario involving branching and merging seemed to resonate with StackOverflow readers even more powerfully.

ps. Regarding logins, I understand your point, but I really want to block spam on my blog. I enabled both blogger logins and openid logins. That will have to do.

Bill Karwin said...

I have updated the post above to recommend git as the source control system you should learn. When I originally wrote this article in 2008, I recommended subversion. Subversion still works but git has become much more popular, and there are advantages to using a distributed source control system.