Do you edit files on both your laptop and another computer and worry about keeping them synchronized? Do you share files with others and want to make sure when they make changes it doesn’t overwrite your own? If so, you should try Subversion, a concurrent versioning system which lets you easily keep files synchronized across multiple systems. Here are some tips for how to use subversion from either the command line or the Windows turtleSVN client.
Subversion’s primary use is for storing code shared by multiple developers, but it also is a handy tool for managing any kind of documents. The idea is that you have an online repository where the current (and all previous) versions of your files are stored. Different users, or yourself from multiple computers, then “check out” files from the server to edit them locally. After editing files, you commit your changes back to the server so they are available to everyone else. If in the meantime, another user has been editing a file, you can update your copy to merge the changes they have made with your own. This can lead to conflicts if two users both edit the same line in a file, but Subversion does its best to help you get around these. Since the server stores backup copies of every change you’ve ever made, you can easily revert to previous versions.
What You Need
- A subversion client
- A place to store the files
- ssh access to a remote server
- a local directory (although this makes less sense unless it is on a USB/removable drive)
- other options like an SVN http server which I won’t explicitly cover
Create a Repository
First you need to create a repository to store your data. The semantics of this depend on where you are keeping your Subversion repository. Here are two common possibilities:
Remote server via ssh: these commands will log into the server “example.edu” with username “user” and create an empty repository in a new “repository” folder off of your home directory. If you want, you can use any directory name and location you like.
svnadmin create /home/user/repository
To get a list of what files are included in a repository, you use the list command. If you’ve just created the repository, there will be nothing to list, but if you are using an existing one, you can try this out.
# On your local machine:
svn list svn+ssh://firstname.lastname@example.org/home/user/repository
Importing and Checking Out Files
If you have already created files which you would like to bring into a repository, you can use the import command.
svn import /home/user/my_proj/ svn+ssh://example.edu/repository/my_proj -m "initial import"
This will take the contents of /home/user/my_proj/ (and all subdirectories) and copy them up to the subversion server.Â The “-m” portion of the command provides a message to be recorded in the repository’s log. These messages are helpful for other people using the repository since it lets them see why you are adding or changing files.