Quick-n-Dirty subversion (svn) using ssh tunnel


apt-get install subversion subversion-tools apache2 libapache2-svn
# Create a new repository
mkdir /data/svnrepos
svnadmin create /data/svnrepos
grpadd svn
#(add the desired users to this group
# - remember they need to restart - even X
# - then
chmod -R g+rw /data/svnrepos
chgrp -R svn /data/svnrepos
# the repository is now ready

#### to import a project
cd to your dev dir eg
cd $HOME/dev
#then
mkdir myproj
cd myproj
mkdir trunk branches tags # trust me add all 3 of these
#edit some files in the trunk dir
cd trunk # $HOME/dev/myproj/trunk
cat "lots of stuff">new.fil



# now drop one dir below your project dir
cd $HOME/dev
svn import -m "myproj START" myproj svn+ssh://username@rhost:/data/svnrepos/

#Then - you *have* to move or remove the old dir out and checkout the proj
#then the .svn dir will be in the project dir making it a working dir.
# This requirement is a little different from cvs
# If the above worked then trust it enough to remove you project directory
rm -r myproj
# Now checkout your project to create you svn working directory tree
svn co svn+ssh://companionway.net/data/svnrepos/myproj/
# Go look to see that you now have svn control files in myproj/.svn
# You should see this assuming you are located in $HOME/dev
@argos ...dev $ ls -la myproj
total 24
drwxr-xr-x 6 geoffm geoffm 4096 2008-02-20 20:02 .
drwxr-xr-x 23 geoffm geoffm 4096 2008-02-20 20:01 ..
drwxr-xr-x 3 geoffm geoffm 4096 2008-02-20 20:01 branches
drwxr-xr-x 6 geoffm geoffm 4096 2008-02-20 20:03 .svn
drwxr-xr-x 3 geoffm geoffm 4096 2008-02-20 20:01 tags
drwxr-xr-x 3 geoffm geoffm 4096 2008-02-20 20:03 trunk

# double check with these commands
cd $HOME/dev/myproj
# Note that you no longer have to declare the location of the repository
# That info is in the control file under the project .svn directory
# The need connection information will be used sutomatically
svn list --verbose -R # long list of files (--verbose) recursively (-R)
# or get the status
svn status --verbose

# get in the habbit of updating your code base from the repository
# before you checkin code - or better, before you modify code or files
svn update
# update your file(s)
cd $HOME/dev/myproj/trunk
echo "more stuff">>new.fil
# to see where you are
cd dev/myproj
svn status
argos ...trunk $ svn status
M new.fil
# Note: the M tells you the file has been modified but not yet checked in

# To add a new file
svn add newfile

# To remove a file
svn remove filename

# Then checkin all the changes
svn ci

# There are a ton of other svn commands but I will leave that up to
# you to learn as you need them
# like revision checkouts, merges, tags, diffs, etc

# Other options for repository access exist but
# I like the simple ssh tunnel shown above
sudo svnserv -d -r /data/svn

#apt-get install cvs2svn - never used - so put notes here

Remember this is just a scratch of the surface.
Enjoy
-g-
This entry was posted in System Admin. Bookmark the permalink.

Leave a Reply