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.
Assumptions
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.
Starting assumptions:
- You have Subversion installed, with the binaries on your path.
- You have a tree of project files in a directory called ‘c:\myproj’.
Prepare your project files
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.
Setting up the repository
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
repository:
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.
Getting a working copy
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.
Tweaking the contents of the repository
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:
*.pyc
*.obj
*.bak - Then use that file to set the svn:ignore property on all directories in your
tree:
$ 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
your repository:
(We used the -m switch to provide a comment, avoiding the editor opening to collect one from us.)$ svn commit -m "Ignoring ignorable files"
Sending .
Committed revision 2.
Working
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
A a-file-I-added.txt
See what you’ve changed with the status (or st for short) command:
$ svn st
A a-file-I-added.txt
M a-file-I-modified.txt
? a-file-I-forgot-to-add.txt
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."
Adding a-file-I-added.txt
Sending a-file-I-modified.txt
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
D unwanted-file.txt
$ svn mv badname.txt goodname.txt
A goodname.txt
D badname.txt
Remember that nothing really happens in the repository until you commit:
$ svn ci -m "Stuff moved around."
Deleting unwanted-file.txt
Adding goodname.txt
Deleting badname.txt
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!
See also
- The online book Version Control with Subversion.
- Subversion branching quick start, which explains how to branch and merge in Subversion.
- My blog, where other similar topics are discussed.
Comments
TortoiseSVN is a joy to use and it’s all you need to get started with Subversion on Windows. Everything you explain here could be greatly simplified or even skipped.
http://ankhsvn.tigris.org/
This guy provided detailed instructions on setting up Subversion on Windows at,
http://www.clearmud.homeip.net/
Also, I didn't know if you had noticed this yet, but this web page has been linked to by 50 different people on http://del.icio.us (as of 4/6/2005). Not too shabby for a tutorial on a blog.
ps -- craig, some people find the command line efficient. Notice how i didn't call you a name...:-)
Now, by reading this article, I though come on, give it a try.
After nearly one hour I have still not yet even imported my project!
First, I had trouble executing this line:
svnadmin create c:\svn\myproj
It didn't work until I moved to c:\svn
Next problem was the import:
svn: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, and no 'editor-cmd' run-time configuration option was found
So I used -m option and the next problem was:
svn: Unable to open an ra_local session to URL
svn: Unable to open repository 'file:///c:/svn/myproj'
So I read that I have to verify if ra_local is installed by typing:
svn --version
which results in:
svn, version 1.2.0 (r14790)
compiled May 22 2005, 22:40:26
Copyright (C) 2000-2005 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository access (RA) modules are available:
* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
- handles 'http' scheme
- handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
So all seams ok but svn refused to import.
Then I remembered that I used TortoiseSVN at the time and I started it. I could get my old repository via file://... protocol.
I don't know why svn doesn't import to my new created repository but one thing is clear: I don't trust into such cranky software and don't want to lose still more time.
Now, by reading this article, I though come on, give it a try.
After nearly one hour I have still not yet even imported my project!
First, I had trouble executing this line:
svnadmin create c:\svn\myproj
It didn't work until I moved to c:\svn
Next problem was the import:
svn: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, and no 'editor-cmd' run-time configuration option was found
So I used -m option and the next problem was:
svn: Unable to open an ra_local session to URL
svn: Unable to open repository 'file:///c:/svn/myproj'
So I read that I have to verify if ra_local is installed by typing:
svn --version
which results in:
svn, version 1.2.0 (r14790)
compiled May 22 2005, 22:40:26
Copyright (C) 2000-2005 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository access (RA) modules are available:
* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
- handles 'http' scheme
- handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
So all seams ok but svn refused to import.
Then I remembered that I used TortoiseSVN at the time and I started it. I could get my old repository via file://... protocol.
I don't know why svn doesn't import to my new created repository but one thing is clear: I don't trust into such cranky software and don't want to lose still more time.
Open your mind!
And I think the command line approach is best for learning as it shows you the basics under those layers of graphics.
When using command 'svn import' always an error is occuring after some files have been added (translation from German): 'svn: File 'd:\svnrepos\askeet\db\transactions\0-1.txn\rev' cannot be opened: The process cannot access the file because it is being used by another process.'
Interestingly folder '0-1.txn' is not being created in repository. And this message is not occuring in a reproducible manner. Sometimes after several tries of importing corresponding folder '0-1.txn' is suddenly emerging!
But I did not achieve a single import. Always after several files have been added, this error is emerging.
Any hints?
for anyone looking for a windows svn installer get one here
It included TortoiseSVN for GUI svn inteface, but I prefer the command line, and these instructions were great.
I ran into a similar issue.
The problem was that my virus scanner on the server was not able to complete it's scan of content written to the transaction data before a new write was attempted by the svn server.
I fixed this by disabling my virus scanning on this section.
(Norton Antivirus File System Protection)
BTW: I live on the command line in Windows because its the foundation for many programs, and anyone serious about learning CVS/SVN - since they started at the command line, one needs to learn the command line. Often I ssh in and the command line has saved me much headache from graphical interfaces not doing exactly what I need - PHPMyAdmin is one fine example. If one is not serious about being a true expert in CVS/SVN, then they should download GUI tools that hide whats going on and click away.
One of the first problems I had was getting past all the svn examples which are for *nix systems and when it said to:
svn import mysourcetree file:///svn/repos -m "a comment"
I took the third forward slash in file:/// to be part of the *nix path
to /svn/repos
So I got stuck on trying to DOS-ify the example by
svn import mysourcetree file://f:\svn\repos
Anyway to make a long story short, you
have the correct incantation in step 3!
I finally got svn 1.4.3 repository created and loaded with my first rails
project and maybe now I wanted to manage it from eclipse via subclipse. Oh yeah babe!
Here begins more problems for anyone who cares.
The mod_dav_svn.so apache modules that came with the one-click DOS installer for svn 1.4.3 were incompatible with the latest apache server version 2.2.4 that I had installed. I went back to the subversion
web site and stumbled on this little note at the top of the download page
ATTENTION!: The mod_dav_svn binaries available here are NOT compatible with Apache 2.2
-- see the Windows Apache 2.2.x folder.
In there, I found the file: svn-win32-1.4.3.zip
with description: Subversion 1.4.3 Win32 binaries for Apache 2.2.x.
The filename is the same as a file in the original directory that apparently has different shared-object libs in it!!!
Anyway, the one-click installer that I originally downloaded and used to install svn does magical things like add the all-important environment variable APR_ICONV_PATH (rrriiiigggghhhht!!) and the zip file does nothing of the sort so it isn't good enough to unzip the apache 2.2 verson of svn. I ended up installing svn via the one-click DOS installer so that at least svn worked by itself. THEN I extracted the svn/bin/mod_dav_svn.so file from the apache 2.2 version of svn-win32-1.4.3.zip and put that file into c:\apache\apache2.2\modules then after some minor http.conf tweeks that actually matched the svn documentation, I was able to get apache to serve up the repository created above!!!!!!!
Bye
Charlles
Brazil & Samba
I have this scenario:
a subversion repository shared between many users with several Netbeans projects inside, and I wish to be able to ignore every warning about differences on directories like nbproject (these contain info on the local settings for each user, thus, being useless keep them on sync).
I tried using nbproject*, *nbproject* and nbproject, but the warnings continues overwhelming me.
What am I doing wrong?
Unable to open an ra_local session to URL
Unable to open repository
I did a perfect install of subversion, repos, a development checkout and a staging area export. I installed tortoise svn and all was beautiful.
Then I rebuilt the UNIX server and TortoiseSVN kept showing me the above errors.
Besides spending alot of time on trying to track down an issue on the UNIX server as I had repaired and reloaded TortoiseSVN and was still getting the errors, I noticed that when I had set up samba some drives that I had mapped had changed, TortoiseSVN kept the old pathways to non existent repository path. This is a windows caching issue or tortoise doesn't destroy all the temp files it makes even when deleted and reinstalled or repaired. I hope this helps to stop wasting time on this issue.
Maybe if I could figure out how to write one of those ignore.txt files? If I only knew which folder it went in and what the syntax is to avoid a few folders by name. Arghhh!
set SVN_EDITOR=c:/windows/notepad.exe
Assuming everything is on the c: for windowsers ->
svn import pj file:///c:/svn_repository -m "init"
Just read a tweet from Scott Hanselman about a new product SVNIsapi (http://www.svnisapi.com) which provides Subversion support via IIS. No need to setup an Apache or SVNSERVE any more.
Thanks mate ... its good to have ppl like u
Add a comment: