Why version control is a life saver…

It was late, and I’d done a long day up to that point. And I was mucking about with some inconsequential code. In fact, I was trying to delete the directory, as I’d finished what I was doing with it.

So I executed that fateful command: rm –rf parserdemo/ *

Now I’m sure almost all my regular readers will know straight away where I went wrong. I didn’t immediately. I was tired, and aching to get home, but after two minutes I thought, “that directory wasn’t that big!!” so I control-c’d it and did an ls.

It wasn’t a pretty sight. Almost every project I’d worked on had gone from my dev directory. Even more worrying was the work I was working on that morning had gone. Now I usually commit my code at the end of the day, (when I remember) so I cd’d in to the the project’s directory, looked ok, maybe I cancelled it in time, but no! I did a git status and got a nasty error message.

Fortunately for me, I actually committed the work earlier that day as I’d finished the ticket I was working on. So fortunately I could blat the directory, re-clone the project and check out against the appropriate branch and sure enough there was the code I’d lovingly written that morning.

The moral of this lesson?

Well first of all, be VERY CAREFUL using rm –rf, because it will just chomp through anything and everything if you’re not careful.

Secondly, if you don’t use version control, then do so.  It’s there for a VERY GOOD REASON.  And these days you can have your code hosted for free on github or bitbucket or any number of free source code repository sites.

Thirdly, commit your changes often. Because you never know when you need to roll back to something you did by mistake. With git this is very easy, I don’t have experience of other version control systems. I do recall using one tool that you had to check out individual files, then check them back in again against a central repository, you didn’t have the code on your hard disk the way you do with git. But I digress.

The fact of the matter is, I was tired and a wee bit irritable by that point of the day, and I hadn’t realised what I’d done until I looked at the command more carefully. But it’s the kind of mistake you’ll only make once.  Hopefully…

Advertisements

About welshboy2008

In my spare time, I read, listen to music, play my guitar among other stuff. I love to write computer programs too. In various languages. But mostly C# and Java. I'm currently learning: PHP, Javascript, XML, ASP.NET, Python, C and Assembler.

Posted on 10/03/2015, in Uncategorized. Bookmark the permalink. 2 Comments.

  1. This is a very good story of why good use of version control is critical. Glad you did not lose too much.

    • welshboy2008

      Cheers Lobster, there was something of a scream in the office when I realised what I’d done, but luckily I was sensible enough to commit little and often. Such a simple mistake to make

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: