Step by step source control setup
by Michael Perry · 02/28/2007 (11:46 am) · 12 comments
Greetings all. Let me go ahead and say it: I am completely stupid when it comes to networking. Networking, meaning routers, servers, etc. After many sleepless nights, and multiple reinstallations of source control programs, I've finally figured out how to run a source control system on my computer.
This is a MUST for a team of developers, because passing around a USB drive full of code and WinMerging each file is doomed to failure and error.
To those who are experienced in setting up such systems, this tutorial will seem simple and might contain extra steps not necessarily needed. But this resource isn't for you, it's for people like me who need step by step instructions to get anything network related running.
Files You Will Need:
Applications Explanation
Apache is your server module, not much more detail is needed except you need to have this running all the time.
Subversion is what actually controls your repository, keeps track of revisions, and is the heart of your source control.
Tortoise is somewhat optional. This wonderful program is a client used for accessing a source control server. You can always pick another client, but what I like about Tortoise is that it integrates into Windows beautifully. Once you install Tortoise, you need to restart the computer, and once you do any folders or files involved in source control have overlays on top of their icon letting you know if a file/folder is up to date, modified, or locked.
Go ahead and install Tortoise and restart Windows before we proceed with your main setup.
Step 1:
Download Apache, Subversion, and Tortoise
Step 2:
Install Apache. Input the following when asked:
Step 3:
Install Subversion. Make sure that "Install and configure Subversion modules..." is checked, which it should be by default. Default installation is recommended.
Step 4:
Edit your Apache httpd.conf file at C:\Program Files\Apache Group\Apache2\conf\httpd.conf. Alternatively, there is a shortcut in the start menu under the Apache program group to edit the file.
Add this at the bottom of the file
Start->Programs->Apache 2.0.59->Manage Apache Server->Restart
Step 5:
Create the following two folders, preferably in the root of a hard drive (c:\):
Password protect the Subversion repository running the cmd console and entering the following:
You can change admin to whatever you want, such as your name or your network admin's name. You'll be prompted to enter a password, do so and press enter.
Step 7:
We are almost done with the setup. There is one tricky thing we have to do, which is add a System Variable in Windows. Do so using the following:
Step 8:
Load the cmd console and type:
Alt + Tab back into Windows.
Step 9:
Edit c:\svn\conf\svnserve.conf, and remove the # symbol before the following lines:
Save and exit.
Step 10:
Edit c:\svn\conf\passwd, and remove the # symbol before the following lines:
Obviously, you want to swap the names "harry" and "sally" for the names of your team members. Also, change "harrysecret" and "sallysecret" to more secure passwords for team mates.
Step 11:
Alt + Tab back to the cmd console, and enter the following:
Step 10:
Open a second cmd console, and enter the following:
Save and exit, then switch back to the cmd console you were just in.
You should be prompted with (c)ontinue, (a)bort, (r)etry. Type c and press enter.
You should now be asked for the Admin password, which is actually the password for your windows logon. If there is no password for Windows logon, just press enter.
The last prompt is asking for a user name, then it will ask for a password. This will be one of the entries you made in the c:\svn\conf\passwd file.
If you typed in the name and password correctly, you should see the following:
Some numbers might be different, but ladies and gentleman, you have source control running.
Using Source Control
These instructions are based on a single folder or file, but I highly recommend you read the Tortoise SVN docs on the website for a full listing of commands and instructions.
Adding a folder
Create a folder on your C:\, let's call it FakeGame.
Create a folder in FakeGame and name it svn.
Put a file in FakeGame\svn, a simple notepad doc will do for now.
Right click on FakeGame\svn, hover over TortoiseSVN until the submenu pops up, and left click on import.
Put the following in the URL of repository: box,
Click OK. You might be prompted for a user name and password, which again, are the entries you put in the c:\svn\conf\passwd file.
By Importing this folder, anything in the folder hierarchy (files and subfolders), will be added to the repository.
If you make a change to a file, simply right click the file, and left click SVN Commit...
Got a new file? Right click the file, and left click TortoiseSVN->Add...
There are a lot more commands and features of TortoiseSVN, but you should be able to figure it out using the docs. If you get stuck, just post here in the resource and I'll help the best that I can.
One disclaimer is that I did not include instructions and configurations for servers and computers that are behind routers. I know how to configure such systems, but I did not include the info here because the steps can change based on your router brand and type. If you are having problems that relate to this issue, you can e-mail me, because I don't want to confuse people with extra steps.
This is a MUST for a team of developers, because passing around a USB drive full of code and WinMerging each file is doomed to failure and error.
To those who are experienced in setting up such systems, this tutorial will seem simple and might contain extra steps not necessarily needed. But this resource isn't for you, it's for people like me who need step by step instructions to get anything network related running.
Files You Will Need:
- Apache 2.0.59 - Download Link
- Subversion 1.3.2 - Download Link
- Tortoise SVN - Download Link
- This setup is for Windows users[li]This will host the source control server on your local machine[li]This setup allows team members to access the source control system from remote locations[li]Security is managed using unique user names and passwords[li]You are going to use the cmd console a lot. To execute the cmd console, do the following:
Start Run Type cmd Press enter Type cd c: <--[b]Gets you to the root of drive [/b] Press enterYou should also write down your IP address, as this is the address remote users use to access the server.
Run the cmd console Type cd c: and press enter Type ipconfig and press enter Write down the entry after IP Address, usually looks like this: 22.22.22.0, just with different numbers.
Applications Explanation
Apache is your server module, not much more detail is needed except you need to have this running all the time.
Subversion is what actually controls your repository, keeps track of revisions, and is the heart of your source control.
Tortoise is somewhat optional. This wonderful program is a client used for accessing a source control server. You can always pick another client, but what I like about Tortoise is that it integrates into Windows beautifully. Once you install Tortoise, you need to restart the computer, and once you do any folders or files involved in source control have overlays on top of their icon letting you know if a file/folder is up to date, modified, or locked.
Go ahead and install Tortoise and restart Windows before we proceed with your main setup.
Step 1:
Download Apache, Subversion, and Tortoise
Step 2:
Install Apache. Input the following when asked:
Network Domain/IP - 127.0.0.1 Server Name - localhost Webmaster Email - YOUR_EMAIL_HERELeave the rest of the installation on default, especially the install path.
Step 3:
Install Subversion. Make sure that "Install and configure Subversion modules..." is checked, which it should be by default. Default installation is recommended.
Step 4:
Edit your Apache httpd.conf file at C:\Program Files\Apache Group\Apache2\conf\httpd.conf. Alternatively, there is a shortcut in the start menu under the Apache program group to edit the file.
Add this at the bottom of the file
# Configure Subversion repository <Location /svn> DAV svn SVNPath "C:\svn" AuthType Basic AuthName "Subversion repository" AuthUserFile "c:\svn_conf\passwd" Require valid-user </Location>Save and exit the file. Restart the Apache server using the short cut found in
Start->Programs->Apache 2.0.59->Manage Apache Server->Restart
Step 5:
Create the following two folders, preferably in the root of a hard drive (c:\):
- svn[li]svn_conf
Password protect the Subversion repository running the cmd console and entering the following:
cd "C:\Program Files\Apache Group\Apache2\bin" htpasswd -c C:\svn_conf\passwd admin
You can change admin to whatever you want, such as your name or your network admin's name. You'll be prompted to enter a password, do so and press enter.
Step 7:
We are almost done with the setup. There is one tricky thing we have to do, which is add a System Variable in Windows. Do so using the following:
Start Settings Control Panel Double click System (depending on your XP theme and visual settings) Click on the Advanced tab Click on the Environment Variables button Under System variables scroll box, click the New button [b]Variable name: SVN_EDITOR Variable value: c:\windows\notepad.exe[/b] Click OK on each window until you are back in Windows.
Step 8:
Load the cmd console and type:
svnadmin create "c:\svn"
Alt + Tab back into Windows.
Step 9:
Edit c:\svn\conf\svnserve.conf, and remove the # symbol before the following lines:
anon-access = read auth-access = write password-db = passwd
Save and exit.
Step 10:
Edit c:\svn\conf\passwd, and remove the # symbol before the following lines:
harry = harryssecret sally = sallyssecret
Obviously, you want to swap the names "harry" and "sally" for the names of your team members. Also, change "harrysecret" and "sallysecret" to more secure passwords for team mates.
Step 11:
Alt + Tab back to the cmd console, and enter the following:
svnserve --daemon --root "C:\svn"Press enter, and at this point you have a running server. You need to leave this window running, so just minimize BUT DO NOT CLOSE IT
Step 10:
Open a second cmd console, and enter the following:
svn mkdir svn://localhost/myprojectmyproject can be renamed to fit your project name. Once you press enter, Notepad should pop up showing you some text like this:
-- This line, and those below, will be ignored -- A svn://localhost/myproject
Save and exit, then switch back to the cmd console you were just in.
You should be prompted with (c)ontinue, (a)bort, (r)etry. Type c and press enter.
You should now be asked for the Admin password, which is actually the password for your windows logon. If there is no password for Windows logon, just press enter.
The last prompt is asking for a user name, then it will ask for a password. This will be one of the entries you made in the c:\svn\conf\passwd file.
If you typed in the name and password correctly, you should see the following:
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.
Some numbers might be different, but ladies and gentleman, you have source control running.
Using Source Control
These instructions are based on a single folder or file, but I highly recommend you read the Tortoise SVN docs on the website for a full listing of commands and instructions.
Adding a folder
Create a folder on your C:\, let's call it FakeGame.
Create a folder in FakeGame and name it svn.
Put a file in FakeGame\svn, a simple notepad doc will do for now.
Right click on FakeGame\svn, hover over TortoiseSVN until the submenu pops up, and left click on import.
Put the following in the URL of repository: box,
svn://YOUR_IP_ADDRESS/YOUR_PROJECT_NAME (might look like this) svn://22.22.22.0/myproject
Click OK. You might be prompted for a user name and password, which again, are the entries you put in the c:\svn\conf\passwd file.
By Importing this folder, anything in the folder hierarchy (files and subfolders), will be added to the repository.
If you make a change to a file, simply right click the file, and left click SVN Commit...
Got a new file? Right click the file, and left click TortoiseSVN->Add...
There are a lot more commands and features of TortoiseSVN, but you should be able to figure it out using the docs. If you get stuck, just post here in the resource and I'll help the best that I can.
One disclaimer is that I did not include instructions and configurations for servers and computers that are behind routers. I know how to configure such systems, but I did not include the info here because the steps can change based on your router brand and type. If you are having problems that relate to this issue, you can e-mail me, because I don't want to confuse people with extra steps.
#2
Dreamhost.com webhosting has a one click subversion install.
So for 10 bucks a month you get unlimited websites, unlimited email, subversion, 172gb of disk space, and 1.72TB of transfer. And all your stuff is backed up to a server online.
I occasionally experience some downtime... but its rare and usually back up within an hour or two.
02/28/2007 (10:56 am)
Another option:Dreamhost.com webhosting has a one click subversion install.
So for 10 bucks a month you get unlimited websites, unlimited email, subversion, 172gb of disk space, and 1.72TB of transfer. And all your stuff is backed up to a server online.
I occasionally experience some downtime... but its rare and usually back up within an hour or two.
#3
@Nick - True, there are tons of options out there for source control. The obvious benefits of outsourcing this task is that there is less work involved.
However, by setting up your own server there is no cost (except for your ISP payment), you have absolute control over the files and project, and no one can touch or look at the source code without you knowing it.
By writing one or two batch files, you can have the backup system as well as a nightly build system (my next resource).
I like having this control, as project lead. We have a rig with 2GB of RAM, 400GB of HD space, and have yet to experience any downtime or major lag.
Well, as you and I have both said, there are plenty of options out there. This is just a great starting point for newcomers to source control.
02/28/2007 (11:16 am)
@David - Nice, I didn't even think to look for that. That's definitely an added bonus@Nick - True, there are tons of options out there for source control. The obvious benefits of outsourcing this task is that there is less work involved.
However, by setting up your own server there is no cost (except for your ISP payment), you have absolute control over the files and project, and no one can touch or look at the source code without you knowing it.
By writing one or two batch files, you can have the backup system as well as a nightly build system (my next resource).
I like having this control, as project lead. We have a rig with 2GB of RAM, 400GB of HD space, and have yet to experience any downtime or major lag.
Well, as you and I have both said, there are plenty of options out there. This is just a great starting point for newcomers to source control.
#4
Didn't mean to sidetrack your blog or anything. Just saw that feature in my dreamhost account this morning and thought this would be a great place to mention it.
I like your setup btw. Way more control.
02/28/2007 (3:58 pm)
Totally.Didn't mean to sidetrack your blog or anything. Just saw that feature in my dreamhost account this morning and thought this would be a great place to mention it.
I like your setup btw. Way more control.
#5
With Dreamhost though, your source is guaranteed to be secure (last I read there policy), so they don't share it with anyone, or look at it. And if they did, you'd have one heck of a legal claim, heh ... Just thought I'd chime in on that topic, since some people may read Michael's comment and think that source control hosting solutions are "insecure" or "public" :)
If it helps, my normal process is as follows -- I have a remote backup site, and a local SVN Repository. I have a cron job (linux server runs my local svn) that runs once a night, which performs a nightly 'backup-build', where I basically backup my entire repository, then it ftp's it to my hosting account for me -- which provides for the 'off site' security that I seek sometimes, such as in the event of a catastrophic HDD failure, etc, etc ... I also mirror the data locally to another drive, the remote backup is more or less my 'disaster recovery plan' ...
02/28/2007 (5:35 pm)
Dreamhost is definately a good option, especially for teams, but for the loan-developer, a local source control option is usually preferred.With Dreamhost though, your source is guaranteed to be secure (last I read there policy), so they don't share it with anyone, or look at it. And if they did, you'd have one heck of a legal claim, heh ... Just thought I'd chime in on that topic, since some people may read Michael's comment and think that source control hosting solutions are "insecure" or "public" :)
If it helps, my normal process is as follows -- I have a remote backup site, and a local SVN Repository. I have a cron job (linux server runs my local svn) that runs once a night, which performs a nightly 'backup-build', where I basically backup my entire repository, then it ftp's it to my hosting account for me -- which provides for the 'off site' security that I seek sometimes, such as in the event of a catastrophic HDD failure, etc, etc ... I also mirror the data locally to another drive, the remote backup is more or less my 'disaster recovery plan' ...
#6
Additionally, if you don't want to run servers at all, subversion supports a file:/// protocol. It only works for checking stuff out on your local machine, but if that's all you need for now, then it's a lot easier and faster;
svn co file://c:\svn\torque\trunk torque
Also, you missed out stuff about trunk/branches/tags. I'd strongly suggest having a flick through the Subversion Red Book. If nothing else, the Quick Start Guide will get you up and running pretty fast.
Gary (-;
02/28/2007 (6:02 pm)
svnserve and DAV are pretty mutually exclusive. There's generally no reason to install both, especially for someone new to the subject.Additionally, if you don't want to run servers at all, subversion supports a file:/// protocol. It only works for checking stuff out on your local machine, but if that's all you need for now, then it's a lot easier and faster;
svn co file://c:\svn\torque\trunk torque
Also, you missed out stuff about trunk/branches/tags. I'd strongly suggest having a flick through the Subversion Red Book. If nothing else, the Quick Start Guide will get you up and running pretty fast.
Gary (-;
#7
Thanks for the feedback and added suggestions all. My next resource is going to build on this, so all other comments and suggestions are welcome.
02/28/2007 (6:24 pm)
trunk/branches/tags are important, but not essential to the initial setup. As with any piece of software, installing and running it is only part of proper usage. You gotta RTFM, and know what you are messing with. Thanks for the feedback and added suggestions all. My next resource is going to build on this, so all other comments and suggestions are welcome.
#8
even for single-developer projects, even for small, one-off single-developer projects, i can't imagine living without source control at this point. backups are good and stuff, but the ability to easily roll back thru past revisions and see where things went wrong or compare the performance of the app today versus two months ago are priceless, and when combined with an off-site server for backup's sake it's.. uh.. more priceless.
plus source control helps a developer keep the app in working shape because of two central philosophies:
1. whatever is checked into the repository should be fully functional
2. check in often
together these help keep the project stable and give realistic estimates of progress.
02/28/2007 (9:55 pm)
this is a great resource.even for single-developer projects, even for small, one-off single-developer projects, i can't imagine living without source control at this point. backups are good and stuff, but the ability to easily roll back thru past revisions and see where things went wrong or compare the performance of the app today versus two months ago are priceless, and when combined with an off-site server for backup's sake it's.. uh.. more priceless.
plus source control helps a developer keep the app in working shape because of two central philosophies:
1. whatever is checked into the repository should be fully functional
2. check in often
together these help keep the project stable and give realistic estimates of progress.
#9
05/08/2007 (11:31 pm)
I just installed this on my machine. The instructions were pretty easy to follow. I would've had a rough time figuring all of this out on my own... Thanks!
#10
06/27/2007 (3:16 pm)
For the life of me, I could never figure out how to get source control working properly. I followed the instructions here and it worked like a charm. Thanks!
#11
11/08/2007 (2:17 pm)
Great resource! I will spend the rest of the day working on getting this setup for my little project. Thanks for the info!
#12
12/14/2007 (9:13 am)
for small developers groups, i propose use only subversion without apache..., see the subversion help. 
Associate David Higgins
DPHCoders.com