Setting up a Subversion Server under Windows

I talked a little bit about what Subversion is in my previous post. Now, let's get it set it up in Windows.

Luckily for us, Joe White has done most of the work already; he has a tremendously helpful post that documents how to set up Subversion. I'll see if I can streamline his excellent post a bit further, and illustrate it with screenshots.

A) Download Subversion

You'll need the latest version of..

B) Install Subversion

  1. Unzip the Windows binaries to a folder of your choice. I chose c:\program files\subversion\ as my path.
  2. Now, add the subversion binaries to the path environment variable for the machine. I used %programfiles%\subversion\bin\

  3. You'll also need another environment variable, SVN_EDITOR, set to the text editor of your choice. I used c:\windows\notepad.exe

C) Create a Repository

  1. Open a command prompt and type
    svnadmin create "c:\Documents and Settings\Subversion Repository"
  2. Navigate to the folder we just created. Within that folder, uncomment the following lines in the /conf/svnserve.conf file:

    [general]
    anon-access = read
    auth-access = write
    password-db = passwd
    

    Next, uncomment these lines in the /conf/passwd file:

    [users]
    harry = harryssecret
    sally = sallyssecret

D) Verify that everything is working

  1. Start the subversion server by issuing this command in the command window:

    svnserve --daemon --root "C:\Documents and Settings\Subversion Repository"
    

  2. Create a project by opening a second command window and entering this command:

    svn mkdir svn://localhost/myproject
    

    It's a standard Subversion convention to have three folders at the root of a project:

    /trunk
    /branches
    /tags

  3. At this point, Notepad should launch:

    Enter any comment you want at the top of the file, then save and exit.

  4. You'll now be prompted for credentials. In my case I was prompted for the administrator credentials as well:

    Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
    Password for 'Administrator': *********
    Authentication realm:  0f1a8b11-d50b-344d-9dc7-0d9ba12e22df
    Username: sally
    Password for 'sally': ************
    
    Committed revision 1.
    

    Congratulations! You just checked a change into Subversion!

E) Start the server as a service

  1. Stop the existing command window that's running svnserve by pressing CTRL+C.
  2. Copy the file SVNService.exe from the zip file of the same name to the subversion\bin folder.
  3. Install the service by issuing the following commands:

    svnservice -install --daemon --root "C:\Documents and Settings\Subversion Repository"
    sc config svnservice start= auto
    net start svnservice
  4. Test the new service by listing all the files in the repository:

    svn ls svn://localhost/
    

    You should see the single project we created earlier, myproject/

F) Set up the shell extension

  1. Run the TortoiseSVN installer. It will tell you to restart, but you don't need to.
  2. Create a project folder somewhere on your hard drive. Right click in that folder and select "SVN Checkout..."



    type svn://localhost/myproject/ for the repository URL and click OK.


  3. Create a new file in that directory. Right click the file and select "TortoiseSVN, Add"


  4. The file hasn't actually been checked in yet. Subversion batches any changes and commits them as one atomic operation. To send all your changes to the server, right click and select "SVN Commit":



And we're done! You now have a networked Subversion server and client set up on your machine. Note that the default port for svnserve is 3690.

For more tips on using subversion, take a look at the free O'Reilly Subversion book.


posted on Monday, January 16, 2006 4:15 PM by jatwood

Comments

# re: Setting up a Subversion Server under Windows

Note that if you're using Subversion with ASP.NET you may want to set the SVN_ASP_DOT_NET_HACK environment variable:

---
http://svn.collab.net/repos/svn/trunk/notes/asp-dot-net-hack.txt

The "_svn" hack is now officially supported: since some versions of ASP.NET don't allow directories beginning with dot (e.g., ".svn", the standard Subversion working copy administrative directory), the svn command line client and svnversion now treat the environment variable SVN_ASP_DOT_NET_HACK specially on Windows. If this variable is set (to any value), they will use "_svn" instead of ".svn". We recommend that all Subversion clients running on Windows take advantage of this behaviour. Note that once the environment variable is set, working copies with standard ".svn" directories will stop working, and will need to be re-checked-out to get "_svn" instead.
Tuesday, January 17, 2006 11:02 AM by Jeff Atwood

# re: Setting up a Subversion Server under Windows

I have been using the Windows shell extension with a Subversion server I setup on Mac OS X, it works perfectly. It is really a revelation working with Subversion when all you have used before it Visual SourceSafe.
Tuesday, January 17, 2006 5:55 PM by Dave Murdock

# re: Setting up a Subversion Server under Windows

Here's another great tutorial on creating a *local* subversion repository on your dev box, using the TortoiseCVS shell tool:

http://www.codefez.com/Home/tabid/36/articleType/ArticleView/articleId/144/CreatingRepositoriesandProjectsinSubversionTrunkTagsBranches.aspx
Monday, February 06, 2006 2:27 PM by Jeff Atwood

# re: Setting up a Subversion Server under Windows

Hi,

Great tutorial.

FYI a while ago I created a complete tutorial on setting up an entire Development environment using Subversion, IIS and all the necessary scripts.

There's a Subversion installer that I use, which greatly simplifies installing Subversion on Windows.

While the tutorial is ASP.Net focused you could easily change this to suit whatever your using.

http://geekswithblogs.net/rwillgoss/archive/2005/10/20/57506.aspx

regards
Ralph
Wednesday, March 15, 2006 2:57 PM by Ralph

# re: Setting up a Subversion Server under Windows

Hmm, I'm having a weird problem. When I tried this out, svn thought my 'program files' directory ends at the source. I've had the same problems with eclipse. Anyone know why this happens? Something wrong with my qutoing or something? Here's the error message for step D:2 [and yes, 'i' is my windows drive]

I:\Documents and Settings\Brian>svn mkdir svn://localhost/myproject
'i:\program' is not recognized as an internal or external command,
operable program or batch file.
svn: system('i:\program files\crimson editor\cedt.exe svn-commit.tmp') returned
1

I:\Documents and Settings\Brian>





Wednesday, March 15, 2006 5:14 PM by apantomimehorse

# re: Setting up a Subversion Server under Windows

I:\Documents and Settings\Brian>svn mkdir svn://localhost/myproject
'i:\program' is not recognized as an internal or external command,
operable program or batch file.
svn: system('i:\program files\crimson editor\cedt.exe svn-commit.tmp') returned
1

I:\Documents and Settings\Brian>


In step B.3, try putting quotes around the path to your editor.
Wednesday, March 15, 2006 6:20 PM by David Frey

# re: Setting up a Subversion Server under Windows

great tutorial, but you could point out that uncommenting in /conf/svnserve.conf & /conf/passwd means deleting the '#' and the following ' ' ;)

and the restart after installing tortoise seems to be required for the tortoise overlay icons in explorer.
Thursday, March 16, 2006 1:42 AM by aha

# re: Setting up a Subversion Server under Windows

In the step C.2, you need to uncomment the line[General] in the /conf/svnserve.conf file and the line [User] in the /conf/passwd file also to make this work.
Thursday, March 16, 2006 11:19 AM by hhoang

# Authenticating against a windows domain server

If you want your logins to be the same as the windows domain login, you need to set up SVN to run through Apache and configure apache to use DAV SVN and SSPI.

In httpd.conf:

LoadModule dav_svn_module "C:/Program Files/Subversion/bin/mod_dav_svn.so"
LoadModule authz_svn_module "C:/Program Files/Subversion/bin/mod_authz_svn.so"
LoadModule dav_svn_module "C:/Program Files/Subversion/bin/mod_dav_svn.so"
LoadModule authz_svn_module "C:/Program Files/Subversion/bin/mod_authz_svn.so"
AddType application/x-httpd-php .php

Also in httpd.conf:

#
# Subversion repository locations
#
<Location /repos>
DAV svn
SVNPath "//server_name/Repository$/repos/"
AuthName "Login using your username and password"
AuthType SSPI
SSPIAuth On
SSPIOfferBasic on
SSPIOmitDomain On
AuthzSVNAccessFile "//server_name/Repository$/repos/svnaccessfile.conf"
require valid-user
</Location>


The svnaccessfile.conf looks like:
# Default access rule for ALL repositories
# Everyone can read/write
[/]
* = rw


Browsing to http://server/repos/ will ask for a username and password, then give you access the repository (if granted).
Thursday, March 16, 2006 5:27 PM by Blowfishie

# Setting up SVN under windows

Monday, March 20, 2006 7:13 AM by Mischa Kroon

# Setting up SVN under windows

Installing:
Step 1
Some more advanced features:
Step 2
And done :P
&amp;nbsp;

&amp;nbsp;
Monday, March 20, 2006 7:24 AM by Mischa Kroon

# Several Question

Hi!
As i worked trough this tutorial, some questions occured.

1. How do i manage several repositories on the machine?
Creation worked, but creating a service for the second service crashed with the prompt:
"Could not create service in service control manager."
Furtheron if i checkout with Tortoise i tried in the URL something like svn //localhost/My Repository/myproject which gave me the error that the project does not exist.
Maybe someone can help me.
thanks, marc
Tuesday, April 04, 2006 3:39 AM by Marc

# re: Setting up a Subversion Server under Windows

Good Beginners Tutorial , Helps me to start in SVN
Wednesday, April 05, 2006 11:11 PM by tamil Selvan

# re: Setting up a Subversion Server under Windows

Actually, there's a better way to do this, which I've employed to run FitNesse as a Windows service as well. See http://wiki.beyondunreal.com/wiki/Setting_Up_A_Subversion_Server
Thursday, April 06, 2006 6:17 AM by Anthony Nassar

# re: Setting up a Subversion Server under Windows

Wonderful, clear, concise, brilliant. This how-to is just what you need in order to start-up with SVN ! Congratulations
Thursday, April 27, 2006 12:29 PM by Edouard Mercier

# re: Setting up a Subversion Server under Windows

Excellent step-by-step tutorial for setting up subversion. It was my first attempt at setting up a repository on windows. I was able to install all three of the items you mentioned and configure it to store repository files on my USB flash drive. Thanks for a simple tutorial that really works!
Wednesday, May 17, 2006 8:15 AM by Matt Pileggi

# re: Setting up a Subversion Server under Windows

You schould explain why one has to copy the "svnservice.exe" to the subversion's installation directory's bin\ directory (E.2)! I installed the SVNService distribution in its own installation directory. I put this directory and subversion\bin\ into the PATH. Installation and configuration of the service succeeded. But when I startet the service with "net start svnservice", I got an error message in german: "das system konnte die eingestellte umgebungsoption nicht finden". I translate this to "the system could not find the environment option". After putting the svnservice.exe into subversion\bin, it worked!
Friday, May 26, 2006 3:40 AM by Michael Schneider

# Svnservice.exe

Hello...
I have been following your blog to install the subversion. On the first day I was successful in installing the subversion server and was trying to configuring the apache server. I messed up with the apache and had to uninstall and reinstall the subversion server. I followed the exact steps that are mentioned above.

After installing the svnservice with the following command

Z:\>svnservice -install --daemon -root "e:\svn" sc config svnservice start = auto net start senservice


The following message is displayed saying that the service is installed.

SVNService installed.
Commandline set: "--daemon" "-root" "e:\svn" "sc" "config" "svnservice" "start"
"=" "auto" "net" "start" "senservice"

but when I try to list the contents of the repository using the following command.

Z:\>svn ls svn://localhost

it shows the following message

svn: Can't connect to host 'localhost': No connection could be made because the
target machine actively refused it.

When I try to start the service using the windows "Service" utility it gives the following error

"Could not start SVNService on local computer"
Error 193: 0xc1

Please help to solve this issue
Thanks and Regards
Wednesday, June 07, 2006 5:39 AM by mita majumdar

# re: Setting up a Subversion Server under Windows

A wonderfull newbie-tutorial for using SVN on Windows!



@mita majumdar
let's have a closer look at your commandline:
Z:\>svnservice -install --daemon -root "e:\svn" sc config svnservice start = auto net start senservice

first, you need to type "--root" (you miss one - )
also, you wrote "senservice" where it has to be "svnservice". correct these typos

second step is to keep in mind that "svnservice", "sc" and "net start" are different commands that need to be issued after each other, not in line! check the tutorial again and you'll see the following:

1st command: svnservice -install --daemon --root "C:\Documents and Settings\Subversion Repository"
2nd command: sc config svnservice start= auto
3rd command: net start svnservice
Tuesday, June 27, 2006 12:11 PM by llama

# Newest Windows Subversion Executable File

I've been setting up Subversion today and going though a lot of posts. Many of the steps listed above can be skipped if you download the install file that automates most of the install - see http://svn1clicksetup.tigris.org/

That's right - once click and it installs the entire subversion program for you, even make the environmental variables. Much quicker, about 10 minutes.

Now I'm trying to figure out 2 things:
1) how to use IIS on Win2k Server with it, and
2) when using TortoiseSVN, how can you make the "Add Folder" command recursive so it pulls in all the subdirectories too? Currently it appears you have to add one folder at a time.
Help!
Friday, July 07, 2006 2:21 PM by MrMMills

# ASP.NET 2.0 Tips and Tricks.... Setting up Subversion at home... Centrino

Wednesday, August 02, 2006 6:46 AM by Andrew Connell [MVP MCMS]

# re: Svnservice.exe

Had the same problem that starting the service did not succeed. Seems to be caused because I created the repository on a mapped network drive. Using c: instead worked. Somewhat strange, when I started the service in debug mode with svnservice -debug, that gave an error message "RegQueryValueEx failed with error 0, type 1", but the service stayed up and I could successfully issue the svn ls command.
Wednesday, August 16, 2006 1:08 AM by Stefan Illner

# Subversion en Windows

Subversion es un sistema para el control de codigo fuente, es decir ayuda al manejo y control de control
Tuesday, August 22, 2006 11:23 AM by Desarrollo .NET

# re: Setting up a Subversion Server under Windows

the url "run Subversion as a windows service" wrapper is wrong.

http://www.clanlib.org/~mbn/svnservice/
Thursday, August 24, 2006 2:52 AM by gema

# re: Setting up a Subversion Server under Windows

Hi,

I was just wondering if you could go over the set up of the environment variable.
I have downloaded the windows binary, and I have extracted the file in the Subversion folder.

I cannot get the notepad window to launch.

Thanks in advance for your help :-)
Saturday, September 16, 2006 10:44 AM by Yanne

# re: Setting up a Subversion Server under Windows

seems that your link (and GEMAs) to "Subversion as a windows service wrapper" is a dead link.

Any ideas how to do this without that wrapper?

Or wher eto get that wrapper?
Thursday, October 19, 2006 2:09 AM by phpWalter

# re: Setting up a Subversion Server under Windows

Link to download Tortoise SVN is broken, it should be http://tortoisesvn.net/downloads.

Also, as phpWalter pointed out, the link to the windows service wrapper is broken.

However, this doesn't really matter if you're installing Subversion version 1.4 as it comes with native support for installing 'svnserve' as a service. More details at http://svn.collab.net/repos/svn/tags/1.4.0/notes/windows-service.txt
Monday, October 23, 2006 11:54 PM by Ryno

# re: Setting up a Subversion Server under Windows

I have been using PowerShell rather than sc and friends.
set-item -path env:SVN_EDITOR -value "c:\Program Files\Vim\vim70\gvim.exe
new-service -name svnserve -binaryPathName '"c:\Program Files\Subversion\bin\svnserve.exe" --service --root "C:\svn-repository"' -displayName "SVN Steward" -startupType Automatic
start-service -name svnserve
Subversion is now installed and running as a service.
Thursday, November 09, 2006 11:58 AM by phreed

# re: Setting up a Subversion Server under Windows

it seems svnservice is no longer at the location specified in the howto. the "sc" command can be used to manually create the entry. your paths may vary, but this did the trick for me:

sc create svn binpath= "\"C:\Program Files\svn\bin\svnserve.exe\" --service --root \"C:\Documents and Settings\Subversion Repository\""

you should see "[SC] CreateService SUCCESS" if all goes well. be sure you don't remove the \'s near the quotes as they are needed by sc to properly parse the quotes needed in the path. also, the spaces after the switches (binpath= ) are required as well. hope this helps someone.
Thursday, December 07, 2006 8:18 AM by Jason Adair

# re: Setting up a Subversion Server under Windows

I had a problem starting the SVNService and I solved it by deleting all the unused (including commented) lines of the config files. Just in case someone face the same problema...
EX:
svnserve.conf
-----------------------
[general]
anon-access = read
auth-access = write
password-db = passwd
-----------------------
passwd
----------------------
[users]
harry = harryssecret
sally = sallyssecret
----------------------

Friday, December 08, 2006 8:14 AM by Daniel

# Another link to download svnservice.zip

I found another place to download the SVNService.zip file:

http://gda.utp.edu.co/pub/svn/

Thanks for a great tutorial!

-- Tammy
Monday, December 11, 2006 10:24 AM by Tammy Cravit

# re: Setting up a Subversion Server under Windows

The URLs for the svn service wrapper did not work for me. However, the project seems to have been moved to Tigris.org:

http://svnservice.tigris.org/
Thursday, January 18, 2007 3:14 AM by Peter Schmidt

# Installing and Setting up Subversion (SVN) Under Windows XP

For a long time I've wanted to start using Subversion. I see all the benefits of using such a system, but I haven't taken the time to learn it. I've installed it (v1.3.2) a long time ago, but I never really did anything with it -- it was simply so I cou
Sunday, March 18, 2007 2:34 PM by mysiteonline™

# SubVersion Server unter Windows einrichten

Einen Svn-Server unter Windows Server 2003 einzurichten ist recht einfach, wenn man eine kleine Starthilfe
Friday, July 06, 2007 2:12 AM by Ansichten und Einsichten

# how to put a repository in the server

Hi
Thanks for your article on subversion setup. I have one work of making one directory of 800MB size among 3 members in a team. I have setup the windows server on windows xp professional system as per the document here. Also, tortoise client also installed on user desktops.

Kindly tell me where should i copy the repository files on the server and what are the steps should follow from clientsystem whenever i access the same ?

Thanks a lot

regards
vijay
Friday, July 20, 2007 4:27 AM by vijay kumar

# links for 2007-07-23



Team System : Setting up a Subversion Server under Windows
(tags: subversion tutorial)


Reverse IP Domain Check DNS Tool
(tags: tool dns lookup)


Monday, July 23, 2007 3:19 PM by That's it

# re: Setting up a Subversion Server under Windows

some people don't deserve good tutorials like this one. everything worked fine for me.

good job and thanks.

cheers,
daniel
Thursday, August 02, 2007 10:18 AM by daniel

# re: Setting up a Subversion Server under Windows

Thank you for the simple, concise and easy to follow tutorial.

The only problem I had was the broken link to the SVNService program (though I found it elsewhere). The rest worked perfectly and it was about 400x easier than getting the Apache2 modules to work :)

Thanks again!
Wednesday, August 15, 2007 3:32 AM by fileoffset

# Setting up Subversion Source Control on Windows 2003 Server

Thursday, November 15, 2007 10:06 AM by ThreeNineConsulting : Gary_Woodfine , IBlog