I spend a lot of time helping coders and companies get going using Subversion so here are my top tips for using subversion:
Use SVN. Trust SVN. Use SVN more. If you’re still making manual backups of your code before you make changes then you’re not using subversion. SVN tracks all changes and lets you revert them – so trust it and then use it. If you want to undo some changes to a file, just do:
# svn revert myfile.cpp
Ok – I do make manual backups sometimes if I’ve concerned I’m going to screw up my working copy.
Delete your sandbox every 2 days. Your sandbox is your working copy – it’s what you checkout from SVN and work on. Every 2 or 3 days, delete it and checkout from scratch again to make sure you’re really working with code that is in SVN.
This is where most people go wrong – they checkout once and use that copy for months, but you should really do is think of the sandbox as dispensable so get into the habit of dispensing with it.
If you’re working on a web project and the directory name matters, just rename it and check out from scratch in its place so you have your old code:
# mv myproject myproject-backup
# svn co http://mysubversion/myproject/trunk myproject
Useful commit messages will help everyone. Something like “update CSS” is useless if the only file you checkin is a .css file. Something like “fix text alignment” is better or, if you run a bug tracker like Redmine you can include the bug number: “fixes #1234″.
Use branches as soon as something goes live. Make sure it is clear to everyone which branch is live and which is still in development. This will save hours of manually copying code from the live branch to development and vise versa.
Keep branches simple because they take time to get used to. The best advice I’ve seen is to make sure most work happens in one place – e.g. the trunk – and use branches for longer, complex work. A tool like GIT or SVK, which lets coders version their changes locally before committing back to you central SVN repository will also help.