SVN: A quick HOWTO
If you do a lot of coding, you will experience the need for versioning your code. I have used CVS before switching to SVN and I can only recommend SVN to you – once you get the hang of it, you will love it. I even use SVN for keeping track of complex HTML templates.
When using SVN for the first time, I followed a tutorial on the net but it was quite misleading and thus I had quite some trouble with checking in and out.
Let’s say we have an application that resides under /var/www/myApp/ and we have a SVN repository over at www.mydomain.com/svn/myAPP (you can create that via svnadmin create myAPP in the svn/ directory).
OK, at first, we have to check out the empty repo to a directory (I use /home/joe/myAPP here):
svn co http://www.mydomain.com/svn/myAPP /home/joe/myAPP
Then, we jump into our temporary repo and create the necessary directories:
cd /home/joe/myAPP
mkdir tags branches
Done? Good. Let’s copy our application to the trunk/ directory:
cp /var/www/myAPP trunk -a
Now we can add our 3 folders to the SVN repository (in fact, we only mark them for addition, they are added once we commit our changes by checking in):
trunk, branches and tags directories are now registered as part of our SVN repo. But hey! Let’s assume we have two folders (private and logs) which we don’t want to be updated when checking in changes to our repository. We can now set ignore rules to avoid them being checked in:
An editor will open – this can be VIM, nano or whatever you have set as your shells default editor. Enter the following lines and save+close:
You can also set single files or wildcard specs to be ignored:
trunk/log/*.log
trunk/private/*
trunk/private/myDocument.txt
Once you’re done, let’s check in our changes to the repo:
svn ci
Now you can enter a message (for the first time I use “initial commit”), save+close and you will notice that SVN works on your changes and gives back a revision number. This is your current version.
Once you’re done, I’d suggest making an update, removing our repo checkout and checking out only trunk/ since you won’t need tags and branches when working locally:
svn up
cd ..
rm -rf myAPP
svn co http://www.mydomain.com/svn/myAPP/trunk myAPP
Now you’re set!
