Subversion server is installed on top of a running Apache HTTPD web server.
Web server must be setup first as described here.
To install Subversion and Apache HTTPD module:
# Install subversion and Apache httpd mod_dav_svn sudo apt-get install subversion libapache2-mod-svn
First, we create the subversion repository:
sudo -u www-data mkdir -p /var/www/svn sudo -u www-data svnadmin create /var/www/svn/project # Create the SVN repository. mkdir svn svn/trunk svn/tags svn/branches sudo -u www-data svn import svn file:///var/www/svn/project -m "Created project" # Alternative (once HTTPS access is enabled): # svn --username user import svn https://svn.tognoli.fr/project -m "Created project" rm -rf svn
Repository must be added to web server configuration.
Note: SVN can uses the authentication mechanism from Apache webserver. The user file can be the same as the website or a specific one.
sudo vi /etc/apache2/sites-available/default-ssl.conf
/etc/apache2/sites-available/default-ssl.conf
<Location /svn> DAV svn SVNParentPath /var/www/svn AuthType Basic AuthName "Depot Subversion" AuthUserFile /var/www/svn.passwd Require valid-user </Location>
# Create the password file sudo htpasswd -c /var/www/svn.passwd user # Restart web server to refresh configuration. sudo /etc/init.d/apache2 restart
Repository can be accessed via any web browser:
firefox https://server/svn/project
To add (import) a directory and all its content to SVN server:
svn --username user import src_dir https://svn.tognoli.fr/project/trunk -m "Initial version"
Note: the imported source directory is not becoming a working copy. The user still need to checkout the repository before modifying further.
To create a working copy of the repository in a local folder:
# Add current directory to svn repository svn import --username user -m "Initial version" . https://svn.tognoli.fr/project/trunk # Create local copy of the SVN repository svn co --username user https://svn.tognoli.fr/project/trunk src
Here are the most useful command to work with SVN:
# Add a file/dir to SVN svn add src svn commit -m "Some comment" src # Review modified files svn status svn diff aFile.txt # Update local copy to latest. svn update # Create a tag. svn copy https://svn.tognoli.fr/project/trunk https://svn.tognoli.fr/project/tags/v1.0 -m "Version 1.0." # Diff vs. a tag. svn diff --old=https://svn.tognoli.fr/pilot/tags/v1.0 --new=https://svn.tognoli.fr/pilot/trunk --diff-cmd meld20-Feb-2019