Subversion & Rails - Implement Your Own Version Control System
This is a wiki article created by HostingRails users. Please login or signup to make edits.
The following steps all happen on the server.
If you want to automate all this to save time - scroll down and check out the script at the bottom that you can use.
1) Make your svn repository
mkdir -p ~/svn/<projectname>
svnadmin create ~/svn/<projectname>
2) Set up a directory to import mkdir -p ~/tmp/<projectname>
cd ~/tmp/<projectname>
mkdir branches
mkdir tags
mkdir trunk
3) Make an empty shell of a rails app as a place holder in trunk cd trunk
rails .
4) Do the initial import of your temp project into svnsvn import ~/tmp/<projectname> file:///home/<username>/svn/<projectname> -m "created project"
5) Clean up afterwards rm -rf ~/tmp/<projectname>
At this stage if all has gone to plan you should have an svn repository at ~/svn/projectname that contains the shell of a rails app
7) Check out a working copy on the server itself
mkdir ~/tmp/workingcopy
cd ~/tmp/workingcopy
svn co file:///home/<username>/svn/<projectname>/trunk <projectname>
8) Tidy up some rails specific things cd <projectname>
svn remove log/*
svn commit -m 'no logs directory in version control please'
svn propset svn:ignore "*.log" log/
svn update log/
svn commit -m 'no log files either'
X) Add anything you want to your svn repository. For example, if you added a css and some images to your '<projectname>/public' directory then from within your working copy (which you made when you did the svn co): svn add sexy.css
svn add img/
svn commit
Y) If you are a Subclipse fan, the URL to use is:
svn+ssh://<username>@<yourdomain.com>/home/<username>/svn/<projectname>
Also, if you are having trouble getting TortoiseSVN to work with Windows, check out this thread
If you don't feel like typing out each individual step above, you can create a script file that does the same thing. Save the code below into a file in your home directory called "setupsvn.sh" (or whatever name you prefer), then chmod 755 it and execute it by typing "./setupsvn.sh <projectname>". This code simply automates the steps outlined above (as of 2007-04-13).
#!/bin/bash
# derived from http://www.hostingrails.com/forums/wiki_thread/4
echo
echo "Setup a new SVN repository under ~/svn/<projectname>"
echo "Usage: $0 <projectname>"
echo
if [ $# == 0 ]
then
exit
fi
PROJECT=$1
echo "Creating SVN repository"
mkdir -p ~/svn/$PROJECT
svnadmin create ~/svn/$PROJECT
mkdir ~/tmp/$PROJECT
cd ~/tmp/$PROJECT
mkdir branches
mkdir tags
mkdir trunk
cd trunk
rails .
echo "Creating initial import of temp project into SVN"
svn import ~/tmp/$PROJECT file:///home/$USER/svn/$PROJECT -m "created project"
cd ~
rm -rf ~/tmp/$PROJECT
echo "Checking out a working copy on the server"
mkdir ~/tmp/workingcopy
cd ~/tmp/workingcopy
svn co file:///home/$USER/svn/$PROJECT/trunk $PROJECT
echo "Cleaning up some rails-specific things..."
cd $PROJECT
svn remove log/*
svn commit -m 'no logs directory in version control please'
svn propset svn:ignore "*.log" log/
svn update log/
svn commit -m 'no log files either'
" " " "
James
Jillian
Simon
William
Dougb
Osh
Scottmotte
Ghens
Geolev