When writing code, put it in version control as early as possible, and commit as you go, with coherent commit messages about what you're changing and why. Don't just wait until you've got a "1.0" release ready and commit the whole thing all at once -- the point of version control is to maintain a history of your coding decisions and why you made them. Make use of it from the inception of your project. That way, months later when you need to debug, change or extend something, you'll be glad you did since you can figure out what you did originally and why you chose to do it that way. It'll also help other people who wish to extend/improve/debug your code to see the design decisions you were making in the first place.
Finally, it serves as a nice "off-site" backup of your work, so that if your laptop is stolen or explodes, you'll still have your brilliant ideas stored in the repository. Remember, if code doesn't exist in multiple places, it doesn't exist at all.
If you are new to version control, here are some tutorials you might find helpful:
- Easy Version Control with Git
- A Visual Guide to Version Control
- Version Control with Subversion
- Git for designers
- Version Control with Subversion 1 (video)
Other useful pages within this site: