Subversion on Windows quick start
Created 5 February 2005, last updated 30 August 2005
I have a number of personal projects that I store in the Subversion version control system. This is my cheat sheet for how to create a new Subversion repository for a project.
These instructions will be most useful to you if you have the same work style as me: projects that only have one developer, the Subversion repository is on the same machine accessed as a file, you run on Windows, and you like using the command-line. If you have other needs, maybe you can adjust these instructions, maybe not.
- You have Subversion installed, with the binaries on your path.
- You have a tree of project files in a directory called ‘c:\myproj’.
Before putting your project in Subversion, you should prepare the project a bit first.
- Backup your project files in case something goes wrong.
- Delete files that you don’t need, either because they are obsolete, or because they are generated files. For example, editor backup files, compiled binary files, or junk you just don’t want anymore.
Now we’re ready to put the project into Subversion. Here’s what you do:
- If you’ve never created a local Subversion repository, choose a place to
put it, and make the directory:
$ mkdir c:\svn
- Create a Subversion repository, using the Windows file path to the repository:
$ svnadmin create c:\svn\myproj
- Import your existing project files into Subversion, using the URL address of the
An editor will pop open to collect a comment from you. This file indicates that just c:\myproj is being added, but Subversion will pull in all of the contents of that directory too. Once you save the file, the existing files will be imported into your new repository.
$ svn import c:\myproj file:///c:/svn/myproj
Congratulations, you’ve created a Subversion repository containing your project.
Now your files are stored in Subversion, but there is no Subversion-aware copy of the files for you to work on. Make that copy by checking out your project from Subversion. You can’t checkout over your original files because Subversion will complain that an object of the same name already exists. Either delete your original files (you backed them up, right?), or checkout to a new directory:
$ rmdir/s/q c:\myproj
$ svn checkout file:///c:/svn/myproj c:\myproj
Now you have your project back where it started, but under Subversion control.
Usually, there are files in your project directory that you don’t want stored in Subversion. These were files you may have cleaned up above. For example, Python produces compiled .pyc files. You can instruct Subversion to ignore these files, so that you don’t accidentally store them in your repository. Subversion can store properties on files and directories as well as the contents. You tell Subversion which files to ignore by setting the svn:ignore property on directories.
- For files that should be universally ignored, create a text file called
ignore.txt. In it, list the file patterns that should be ignored, one per line:
- Then use that file to set the svn:ignore property on all directories in your
$ svn propset -R svn:ignore . -F ignore.txt
property 'svn:ignore' set (recursively) on '.'
- If certain directories should have other files ignored, you can edit the property
on those directories:
A text editor will open, with the list of ignored files. Edit the list however you want, then save the file and close the editor.
$ svn propedit svn:ignore .
- The changes you’ve made to the directories now have to be committed back into
(We used the -m switch to provide a comment, avoiding the editor opening to collect one from us.)
$ svn commit -m "Ignoring ignorable files"
Committed revision 2.
Now you work on your project. You can change files without checking them out first. The files are writable, and Subversion has its own copy so it can tell what has changed.
To add a new file to your project, create the file, then tell Subversion about it with the add command:
$ svn add a-file-I-added.txt
See what you’ve changed with the status (or st for short) command:
$ svn st
Changes get committed back to the repository with the commit (or ci) command:
$ svn ci -m "Put a comment here, or an editor opens to get one."
Committed revision 3.
Files can be deleted with the remove (or rm) command, and moved or renamed with the move (mv) command:
$ svn rm unwanted-file.txt
$ svn mv badname.txt goodname.txt
Remember that nothing really happens in the repository until you commit:
$ svn ci -m "Stuff moved around."
Committed revision 4.
Occasionally, you should pull changes from the repository. Use the update (or up) command to do this:
$ svn up
At revision 4.
Even though you are the only one working on the project, your working copy isn’t really at the latest revision until you update it from the repository. For example, the “svn log” command shows the history of changes, but only up to your latest “svn update” revision.
That’s all there is to it: now go be productive!