Here I'm going to describe the steps to get subversion up and running. I am using Debian Etch as the preferred OS. Access to the repository will be done via apache (secured with SSL)
Install the needed packages:
apt-get install apache2 subversion libapache2-svn subversion-tools
Create your subversion repository
mkdir /srv/svn cd /srv/svn svnadmin create repos # change owner to apache chown -R www-data.www-data svn/
Create a (self signed) certificate for SSL:
mkdir /etc/apache2/ssl # Generate a private key cd /etc/apache2/ssl openssl genrsa -out host.key 1024 # Generate a certificate signing request openssl req -new -key host.key -out host.csr # Get the certificate signed openssl x509 -req -days 730 -in host.csr -out host.crt -signkey host.key
Make sure all needed modules are enabled for apache
a2enmod ssl a2enmod dav a2enmod dav_svn
Add port 443 (SSL) to /etc/apache2/ports.conf and remove port 80 (I don't want unsecured access to apache). So ports.conf should look like:
Listen 443
Create your authfile for apache basic auth:
cd /etc/apache2 htpasswd -m .htpasswd svnuser
Create your /etc/apache2/svn-authzfile:
# read access for all [/] * = r # rw access only for svnuser in "repos": [repos:/] svnuser = rw
Edit your apache configuration to enalble subversion. First I disable the “default” site:
a2dissite default
Create a new site (e.g. svn): editor /etc/apache2/sites-available/svn
<VirtualHost _default_:443>
ServerName svn.domain.tld
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/host.crt
SSLCertificateKeyFile /etc/apache2/ssl/host.key
ServerAdmin webmaster@localhost
DocumentRoot /srv/svn/
<Directory /srv/svn/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Location /svn>
DAV svn
# any "/svn/foo" URL will map to a repository /srv/svn/foo
SVNParentPath /srv/svn
# our access control policy
AuthzSVNAccessFile /etc/apache2/svn-authzfile
SSLVerifyClient none
SSLOptions +StdEnvVars
# try anonymous access first, resort to real
# authentication if necessary.
Satisfy Any
Require valid-user
# how to authenticate a user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/apache2/.htpasswd
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
DavDepthInfinity on
</Location>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
Activate the new site:
a2ensite svn
Reload apache
#first check if configs are ok: apache2ctl configtest #then reload /etc/init.d/apache2 force-reload
Ready for action …
Common tasks you would perform with your fresh subversion install
Assumption: you have created your initial repository layout and want to import this layout into your repository called “workbench”:
cd ~/tmp ls workbench svn import workbench/backup+restore/ https://svn.domain.tld/svn/workbench
Get help:
svn help svn help command
Update your working copy:
svn up
Revert to an specific revision:
svn up -r 14
Commit a changeset:
svn ci -m "logentry what I did"
Checkout a subdirectory of your repos:
svn co file:///path/to/repos/subdir/
See which files were modified in your working copy:
svn stat
Add a file to your repos:
svn add file
Add all files in a directory to your repos:
svn add dir/
Only add a directory (without the files within)
svn add --non-recursive dir/
List all the files in the current working copy which are under version control:
svn list -Rv
Sometimes it is handy to see (printed in the file) which version of a given file you're using. You can activate some keywords for a specific file:
svn propset svn:keywords "Date URL Revision" .bash_login
Or if you want to set keywords for all files from here:
find . -type f -exec svn propset svn:keywords "Id URL" {} \;
Add the following keywords to your file:
$LastChangedDate$ $Revision$ $URL$
And you will get something like this (after commiting your changes):
#---------------------------------------- # $LastChangedDate: 2007-02-07 13:26:22 +0100 (Mi, 07 Feb 2007) $ # $Revision: 2 $ # $URL: https://svn.domain.tld/svn/repos/.bash_login $ #---------------------------------------- export LS_OPTIONS='--color=auto' eval `dircolors` alias ls='ls $LS_OPTIONS' alias ll='ls $LS_OPTIONS -l' alias l='ls $LS_OPTIONS -lA' [...]
Available Keywords:
You'll want to customize some aspects of your repositories as well as your personal subversion config.
~/.subversion/config
[helpers] editor-cmd = joe [miscellany] log-encoding = latin1 global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store enable-auto-props = yes [auto-props] *.conf = svn:keywords="Id URL"
I had to move my repository to a new location on an nfs volume. What I did:
In detail:
svnadmin dump oldrepos > oldrepos.dump svnadmin create newrepos # if on an nfs-volume, install nfs-utils, then: /etc/init.d/nfslock start svnadmin load newrepos < oldrepos.dump # in existing working copy run svn switch --relocate file:///path/to/oldrepos file:///path/to/newrepos