Mar 18
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 could interact with SmartSVN (a SVN client) to download others' repositories. I think it's about time I start using it in a more meaningful way on my own projects. In order to do this, I thought it would be best to start from scratch (and therefore uninstalled all previous, remotely related software). (For further learning on SVN, please visit Red-Bean's SVN Book online.)

So, it had been so long since I've done anything with Subversion, where was I to begin? I've read about all the great and wonderful things SVN can offer, but...how do I get it, how do I install it, and then how can I access it?
Edit: UPDATE! If you don't want to do all the work yourself, you can now use an all-in-one installation package. VisualSVN Server/ will install Apache, Subversion, and a management console for the Windows' platform.

Perfect timing! Shane Bauer, a Microsoft Certified Engineer (MCE) in ASP.NET, decided to take time out of his day to answer someone else's question on the matter in a forum that I frequently visit. (Link to the topic.) If you'd prefer pictures (but ignore the "run as service" portion) follow the steps on Vertigo Software's instructions.

The following is basically a cut and paste of Shane's post, simply because it was well written:
Subversion is a great product. In fact, I hooked it up to Apache in my home environment as well as my work's environment. After using it for a while my only reaction is: wow. Subversion is awesome. Adding Apache just makes in that much nicer.

Setup is actually pretty straightforward. To use SVN in standalone mode (without Apache), just download the installer (I used svn-1.4.2-setup.exe).

Installing Subversion
- Double-click on the installer and run through it. Shouldn't take too long. Once installed, add an environment variable for SVN_EDITOR. You can do this by right-click on my Computer > Properties. Go to advanced. Hit the Environmental Variables button. Just add another in there called SVN_EDITOR with a value of C:\windows\notepad.exe

Creating a Repository
- Now you need to create a repository. Go to the command prompt (Start > run > cmd). type "svnadmin create D:\Programming\MySVNRepos". (Change the path to whatever path you want to use.) The repos is basically a special directory that will hold your files as well as various subversion config options.

Modifying Security and Authentication Settings
- Next up, you need to modify the permissions and users. Navigate to the folder you just created. In my example, I used D:\Programming\MySVNRepos". In this directory, you will find a few folders. One folder will be called conf. Navigate to it and double-click on the svnserv.conf file. Opening it with notepad will be fine.

- The svnserv.conf file in a configuration file for the svnserv executible. For our purposes, just uncomment out the following lines:

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


- Save your changes. And double-click on the passwd file in the same directory. The file stores all usernames and passwords in the format:

$username = $password

- Make sure the [Users] line is uncommented and you can just add a new line for your username and password. For example, if you wanted your username to be josh and your password to be testing, just create a line like this:

josh = testing

- Save it and you're done configuring.

Serving Your Repos for the First Time
Now, you can test it out. Go to the command prompt again and type:

svnserve --daemon --root "D:\Programming\MySVNRepos"

Change the path to your specified path. Once this is done, the daemon should be listening and waiting for requests.

Creating your First Project folder
- Next, we can create a project folder in subversion. To do this, open up a new command prompt. We can't use the old one as our daemon will shutdown. Once you're in the new window, type the following:

svn mkdir svn://localhost/TestProject


- Once you type this in, notepad will appear (assuming you set the SVN_EDITOR variable at the very beginning). This is basically used for the log so you can just leave it be for our test example and close it out.

- After you close out notepad, subversion will ask for your username and password. However, keep in mind, it may also ask for your computer's Admin password. If it does, you can simply type in your computer's admin password. Once you hit return, you can then go ahead and type in your subversion username and then your subversion password. Your subversion username and password is exactly what you typed in the passwd file. (i.e. user: josh pass:testing)

- If you've successfully typed in your username and password, it should say Commited Revision 1. This is a good thing.

Finishing Up
- After that's completed, you're basically done. Your subversion repos has been setup. However, we have a few problems.
  1. You probably don't want the command window up all the time when running your subversion daemon.
  2. Accessing subversion via command prompt is ok, but it could be better.


Running svnserv as a Windows Service
If you're running XP (Win2k, Win2k3, or Vista), you can tell the process to run as a service. Stop your existing svnserv daemon by closing out of the existing command prompt window. Now, go to the command prompt (again). Type:

sc create svnrepos binpath= "\"C:\program files\subversion\bin\svnserve.exe\" --service --root \"D:\Programming\MySVNRepos" displayname= "Subversion Repository" depend= Tcpip start= auto

Ed. Note: The key/value pairs must be in the form key=_value where the underscore is representative of a space. Also, if you mess up here and the service is still installed, you will need to uninstall the service. You can do so by using sc delete svnrepos (or whatever service name you used). You will need to log off and back on for the service to be completely uninstalled. Also, the "Subversion Repository" is simply a label, you may also call this whatever you'd like.

This simply creates a new service in Windows. Of course, you will need to replace "D:\Programming\MySVNRepos" with the path to your repos that you created. Assuming that you install subversion in the default location, you should just have to run that. Now, just start it by typing:

net start svnrepos


You're done. If you want to change some service settings, such as turning on auto start, just go to Start > run. Type services.msc. Find the service with the Display Name set to "Subversion Repository", right-click on it and select Properties. You can change a few different things in there.

Download TortoiseSVN
Go to tortoisesvn.tigris.org and download TortoiseSVN. The tool is essentially a Windows shell extension that allows you to execute SVN commands from Windows Explorer. It's, honestly, the only subversion tool you really need if you're on a Windows computer. Once you install this, you can then view your repos via a tree view type situation.

For example, go to start > run and type:
svn://localhost


If your service/daemon is started, you should be able to expand the nodes to view your projects and files. You can also create new folders and do a plethora of different tasks in it as well. Also, if you go into Windows explorer, and right-click on any folder, you'll see a new TortoiseSVN submenu, with a few different options. You can then easily import an entire project folder into subversion with ease.

That's It!

Well, now it's time for me to go figure out how to integrate Apache 2.2 with SVN, if at all possible...or get Trac installed since I have that too. :-)

Posted by Brendon Kozlowski

3 Trackbacks

  1. Darkware, Inc. Blog

    Setting up SVN on Windows 2003
    I found the following very useful information on how to set up SVN on a Windows 2003 server. I found it http://life.mysiteonline.org/archives/67-Installing-and-Setting-up-Subversion-SVN-Under-Windows- ...

  2. Ohad Aston

    ????? ??? ?????? ??????
    ?? ???? ???????? ?? ???? ???, ????? ???? ?? ???????, ????? ?????? ??? ????? ???????? - ?? ?????? ?????

  3. Ohad Aston - ASP.NET Blog

    גיבוי קוד וניהול גרסאות
    אם נושא הגיבויים לא חשוב לכם, כנראה שאתם לא מתכנתים, ובגלל שהבלוג הזה מיועד למתכנתים - אז החלטתי לכתוב

14 Comments

Display comments as(Linear | Threaded)
  1. Morgan Hua says:

    I was able to integrate with Apache 2.2.3

    Here's the additional articles needed to complete the installation:

    Win32 - SVN + Apache + Tortoise SVN + SVN Notify How-To (but uses wrong libraries):
    http://svn.haxx.se/users/archive-2006-05/att-0593/SVN-Apache-SVNNotify-HowTo-En.pdf

    Getting the right libraries for Apache 2.2.X
    http://subversion.open.collab.net/servlets/ProjectForumMessageView?forumID=42&messageID=783

    The SVN libraries compatible with Apache 2.2.x (mentioned in the article above, but really hard to find) are located here:
    http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=8100&expandFolder=8100&folderID=91
    http://subversion.tigris.org/files/documents/15/36104/svn-win32-1.4.3.zip

    Thanks for all your details, it helped a lot.

  2. Brendon Kozlowski says:

    Thank you both for the comments! They're quite helpful. Much appreciated!

  3. Arun says:

    Thanks for the detailed instructions. I'm having hardtime configuring Openssh with SVN on the server side. Here's my configuration - Subversion 1.44 on Windows 2003.

    Has anyone tried configuring SSH on SVN+Windows2003 server? Can you please pass on the instructions. Appreciate your help. Thanks.

  4. Brendon Kozlowski says:

    Arun, I apologize for not seeing your reply sooner. I still have not worked with Subversion all that much, even if I know I need to and keep saying I will. However, the following links may be of help to you:

    someone with similar problems - mailing list archive
    probably not as helpful - forum topic
    probably a good bet

  5. venkat says:

    about subversion details

  6. Ing says:

    Hello!

    Not able to install the service on Vista, getting access denied when typing in the lines .... I am the admin on this machine.
    Any suggestions ?

  7. Brendon Kozlowski says:

    Ing,

    I can only presume it has something to do with a user in the Administrator's Group not actually having the full rights as the real Administrator under Vista. I unfortunately do not have Vista installed on any of my PCs yet so am unable to test this out to find a workaround. However, you may find the following project to be helpful:
    SVN Automated Windows' Install
    I'm not sure if it's Vista compatible, but it can't hurt to try.

  8. Sangharsha Bhattarai says:

    Excellent one.
    I was looking for the svn setup instructions since long, and with this, my search ends.

    Thanks a lot Shane Bauer for the article, and Brendon Kozlowski for echoing it here.
    Great Job!

  9. fabian mejia says:

    Also, please check my page.
    I have added a small tutorial to instal a subversion package: VisualSVN for windows. It's really easy to setup:

    fabianmejia.blogspot.com

  10. Brendon Kozlowski says:

    Thank you for your comment, fabian!

  11. tom says:

    i have just done it on Vista, you ned to right click on command prompt and run as administrator.

    :-)

  12. husal says:

    perfect, it help me a lot while setting SVN on my xP

  13. lohith says:

    Hi this lohith
    i am configuring the SVN
    i am un able to Creating a Repository
    how can i create repository

  14. Brendon Kozlowski says:

    Examples:
    Windows -
    svnadmin create C:/full/path/to/your/repository

    Linux:
    svnadmin create /usr/local/full/path/to/your/repository

Add Comment


Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

BBCode format allowed