How To Set Up An SVN Repository In 7 Simple Steps
For some time now, I've wanted to have an svn set up on my shared web host similar to what we have here at civicactions. Having to make changes on my local machine for any personal (non-civicactions client) sites, then scp those files up to my server is ridiculous -- especially since when working on client sites, I've become so used to simply commiting the changes to a repository and then updating that repository on the server side. All that said though, I kept putting off the svn set up because as a simple drupal and civicrm developer, I was afraid that a system admin task like setting up svn would be too involved and maybe a bit over my head. Turns out, I should've done it months ago. It's crazy easy!
Lucky for me, my shared host already had svn installed at /usr/bin/svn. If you're not so lucky, then you'll need to install svn yourself. Depending on your system and your set up, there are multiple ways to do this. For this and all other svn questions, I'd recommend the svn red book. One of the finest examples of open source software documentation I've ever seen. Extremelyhelpful. Of course, if you're on a shared host like me, then you probably won't have the access you need in order to install svn. In that case, contact your system administrator and ask them to install svn for you.
and add the following:
Now you'll need to create a password file:
Add a line in that file for your user in the format =
Now you're almost there. Next, you'll need to import the files you want to keep under version control into your new repository. Do that with the svn import command.
Step 1
Make sure that svn is installed on your web host. Just ssh into your account and typewhich svn
Step 2
Create your repository. Once svn is installed on your host, you can proceed with the repository set up. Just ssh into your server and create a repository wherever you'd like it. In my case I put my repository in my user directory. I would've preferred to have it in the root directory, but because it's a shared host, I don't have write access to anything outside of my user directory. To create the repository, issue the following command:svnadmin create ~/myrepository
Step 3
Create your SVN user: Now that your repository is successfully set up, you'll need to create an svn user. Simply open the svnserve.conf file in the editor of your choice:pico ~/myrepository/conf/svnserve.conf
anon-access = none
auth-access = write
password-db = passwd
pico ~/myrepository/conf/passwd
exampleuser = examplepassword
Step 4
Create a hierarchy for your repository: This step is optional. It's not needed in order to get svn to work properly, but if you're planning on keeping multiple projects under revision control, then it's a good idea to get organized before you start importing those projects. In my case, I'll be working on upgrading one of my sites from Drupal 5 to Drupal 6 soon (yes, I know... I've been putting that off too.), so I wanted a trunk for the Drupal 5 project and a trunk for the soon-to-be-upgraded Drupal 6 project. You can create directories in your repository in almost the same way you create them on your file system, using mkdir. You'll need to use svn's mkdir command though like so: NOTE: Relative paths don't seem to work here. svn doesn't seem to like '~', so remember to start with the root directory (so it'll look like 'file:///root/rest/of/path...'. With three forward slashes.svn mkdir file:///path to your repository/myrepository/d5
svn mkdir file:///path to your repository/myrepository/d6
svn import /path to your project/myD5project file:///path to your repository/myrepository/d5
svn import /path to your project/myD6project file:///path to your repository/myrepository/d6
Step 5
Run the svn server as daemon:svnserve -d
Step 6
Check out your repository onto your local machine: Back on your local machine, go to where you keep your nerd stuff. In my case it's in ~/workspace. Then use the svn co command to check out a copy of your project.cd ~/workspace
svn co svn+ssh://username@hostname/path to repository/myrepository/d6
Step 7
Go get a tasty beverage and rest comfortably in the knowledge that you'll never have to scp another file again. Well, except for maybe the occasional mysqldump file...Share it!
Donald Harper August 31, 2011
You might check to make sure that you have the proper directories listed in step 4. I've seen that error when i either had a trailing slash, However, if I were doing this now for my own use, I would probably use Git instead of svn.You should keep captcha right below the text area, I missed to see it or just hit enter Thank you.
Anonymous (not verified) August 29, 2011
dear siri want how to configure for connect svn sever linux to windows.
Anonymous (not verified) July 30, 2011
On step 4 I get the following error:svn: '.' is not a working copy
Gregory Heller August 1, 2011
You might check to make sure that you have the proper directories listed in step 4. I've seen that error when i either had a trailing slash, or was missing a period to indicate the current directory. You can also try "svn cleanup ." from the directory you are having trouble with.
Anonymous (not verified) July 16, 2011
i created a folder "d5" with svn mkdir. then i import a file "whatever" into that folder using svn import but i get error:svn: Path 'file:///.........../db5' already existsbut if i introduce ANOTHER_FOLDER then it imports it.
svn mkdir file:///path to your repository/myrepository/d6
svn import /path to your project/myD5project file:///path to your repository/myrepository/d5/ANOTHER_FOLDER
Anonymous (not verified) July 16, 2011
i created a folder "asdf" with svn mkdir. then i import a file "whatever" into that folder using svn import but i get error svn path already exists.
vinay (not verified) March 23, 2011
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) optionssvn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, and no 'editor-cmd' run-time configuration option was found can any one guide me here?
Rob (not verified) January 25, 2011
Not sure why you would use svnserve, much better to use apache to serve svn.http://www.duchnik.com/tutorials/vc/installing-and-configuring-svn-on-ce...cheers!
Joe (not verified) October 19, 2010
Do you know if you have to have Apache 2 installed, or will good old Apache 1.3.42 do?
alaken June 9, 2010
I did this a few years ago, not on a shared hosting account but on a VPS I have at Slicehost. Slicehost has an amazing collection of well-written articles on all kinds of sysadmin and LAMP topics. With their articles on Subversion I was able to get my repo up and running easily.
That series of articles will lead you through the process and give you a bit more detail about security, multiple repositories, and while very easy to follow, explain some of the 'why' behind the 'how'.
Here are some slides from a presentation a colleague and I did on Git and SVN a month or two ago: Version Control with SVN and Git.
However, if I were doing this now for my own use, I would probably use Git instead of svn.
That series of articles will lead you through the process and give you a bit more detail about security, multiple repositories, and while very easy to follow, explain some of the 'why' behind the 'how'.
Here are some slides from a presentation a colleague and I did on Git and SVN a month or two ago: Version Control with SVN and Git.
However, if I were doing this now for my own use, I would probably use Git instead of svn.
dan (not verified) June 6, 2010
Thank you for writing this, I was really looking for it. So far I have only used on Windows SVN without command line but mouse, right click left click to checkout or commit etc and only for local development never tried at hosting company account.
I wish you would have created a screenshot based version.
Info may be helpful to you:
a. when I searched your page was in top 6 on google
b. I can't see this specific article/post at any other web page
c. What hosting company you did this svn stuff, mine is Godaddy
d. I often get the development by myself or independent contractor so want to keep track using svn type tool/process
SUGGESTION:
You should keep captcha right below the text area, I missed to see it or just hit enter
Thank you.
I wish you would have created a screenshot based version.
Info may be helpful to you:
a. when I searched your page was in top 6 on google
b. I can't see this specific article/post at any other web page
c. What hosting company you did this svn stuff, mine is Godaddy
d. I often get the development by myself or independent contractor so want to keep track using svn type tool/process
SUGGESTION:
You should keep captcha right below the text area, I missed to see it or just hit enter
Thank you.
Upcoming Events
There are no events to note, hopefully soon.
Stay Connected
SIGNUP FOR OUR FREEEMAIL NEWSLETTER | |
SUBSCRIBE TO OURBLOG RSS FEED | |
SUBSCRIBE TO OURBLOG EMAIL UPDATES | |
FOLLOW US@CIVICACTIONS | |
FOLLOW OURTEAM MEMBERS | |
CONNECT WITH USON LINKEDIN |
Recent Blog Posts
- Transforming Government Technology though Agile Software Development
- Congratulations Ben Kallos - Taking Civic Action Seriously
- The Agile Estate Sale
- Distributed Agile Teams - A reminder to make it great
- Module Development in Drupal 8
- Brainstorming and Prioritizing with Trello
- Meet Us At Drupalcamp This Weekend - New York City, Toronto & Los Angeles
- Improving our Agile Practice
- Youthbuild USA in the news
- CiviCRM and Drupal Commons