September 25, 2008

Simple Revision Control

Many people (including some of my family members) do not use revision control or even know what it is. They have lots of files with funny extensions on their computers (doc1.doc, doc2.doc, doc3.doc) that are different versions of the same document. Sometimes there will be many folders or a combination of files and folders; all in the name of being able to go back in time to see what something used to look like, so that information is permanently lost when you overwrite it.

I think that's terrible and I'm trying to convince my family members to use revision control since it solves this problem nicely, thus the reason for this post. It it very simplified, but should be more than adequate for most computer users to help keep track of changes to their files.



Download and install this: http://tortoisesvn.net/downloads. It is a Windows "extension" -- meaning when you right-click on files and folders you will have a new menu to choose from after you reboot after installation. The program is called "TortoiseSVN" -- it's free and (I think) very usable and convenient.

Here are the basics of revision control:
  1. Everything you want to keep track of is centrally stored in a repository
  2. When you want to make changes to something in a repository, you do a check-out into a folder on your computer
  3. The folder that you checked out in step 2 is called a working copy
  4. When you make changes and want to save them, you commit your changes to the repository, when you do so you provide a comment stating what your change was. This comment is recorded in the log for that file or directory.
  5. You can browse a repository, and for any file or folder inside it you can see its full history of commits (changes), as well as each log message.
  6. In addition to seeing a full history of changes, you can also see the contents of a file/directory at any point in time, so if you decide you don't like a change or need to find something you wrote a long time ago, you can find it.
This tool "TortoiseSVN" enhances the regular Windows Explorer to give you the functionality, using the "Subversion" software ("SVN" for short). It's what many companies and independent projects use to track changes to their work. And while organizations and groups have advanced usage of it, what I described here can be used by anyone with a computer who makes changes to their files over time; spreadsheets, documents, pictures, financial files... anything you might change over time.

To set it up:
  1. Create a repository. Make a new folder somewhere (perhaps C:\repo or something obvious), right-click on it and from the TortoiseSVN menu choose "Create repository here"
  2. Create a working copy. Go make a new directory under "My Documents" (or someplace else you will remember) -- this is a directory where you will be loading/saving your documents from. Right-click on it and choose "SVN Checkout," then for the "URL of repository" put in "file:///C:/repo", then choose "Ok". If you chose something other than "C:\repo", just put "file:///C:/" to start with, then browse to it using the box to the right.
  3. Collect your files you want to keep track of. If you have them, copy your existing documents into your working copy folder. You can put anything you want in there including files, folders (and sub-folders), whatever.
  4. Add your existing files to SVN. SVN wants to be told explicitly what to worry about and what not to, so if you see icons with a question mark by them (as you now should), you can right click on them and choose "Add" from the menu. The icons should change to plus signs at that point -- they are poised to be controled by SVN now.
  5. Commit your new files/folders. Once you have placed your existing documents in your working copy, right-click on the working copy folder and choose "SVN Commit..." from the menu. Enter a comment and hit "Ok" -- you just made your first revision!
To use it day to day:
  1. Stay up to date. At any time you can right-click on your working copy and choose "SVN Update" from the menu to make sure everything is in order.
  2. Edit your files. Make whatever changes you want to your files, add new files or folders, etc. Make sure when you are done that you explicitly add new files -- they will have a question mark icon next to them so they should be easy to identify.
  3. Commit your changes. When you reach what you think is a good point in time to save your work, commit your changes like you did above. Perhaps you added an important idea (even if it isn't finished yet), updated your address book with a new contact, updated your resume, whatever makes sense for you.
  4. Go to step 1.
That's it! At any point you can right-click on your working copy, choose "Show log" from the TortoiseSVN menu, and instantly see a complete trail of all your commits including what files were changed/modified/removed, when you did it, and what comment you wrote when you committed each change.

Hopefully that is enough to get everyone going, and hopefully it is intuitive enough from this point how to use TortoiseSVN to do what you want. If you need more information please leave a comment here, or you can see the TortoiseSVN website at http://tortoisesvn.net/ or the Subversion book online at http://svnbook.red-bean.com/en/1.5/index.html.

1 comment:

josrodin said...

Thanks a lot for the article on svn, it helped me have a version history of my resume :)