Setting up SVN on linux

This is a simple step-by-step setup for a svn server which can be accessed via the internet by multiple people. Basic!

  1. Create a svn repository for your particular project, for example the directory /svn/myproject. Make sure you own the directory: sudo chown YOU:YOU /svn/myproject
  2. Now initiate the SVN system: svnadmin create /svn/myproject This creates a repository in the svn directory.
  3. Now we want to import the files into the SVN directory. cd into the directory you want to use SVN on and do svn import DIR_YOU_WANT_TO_IMPORT file:///svn/myproject. Note that you HAVE TO import directories, SVN only works on directory structures, not on individual files. It will prompt you to enter some kind of log message so you remember why and what you imported.
  4. To locally edit a file, you get a local copy of what's in the repository by doing svn checkout DIR_CONTAINING_YOUR_FILE. Once you're done with editing, and want to commit the changes to the SVN, run svn commit DIR_YOU_EDITED
  5. If you later on want to add a file, get a copy of the directory as above, put the file into the directory and do svn add FILENAME. Similarly, if you want to remove a file, remove it from your local copy and run svn remove FILENAME.
  6. Now we'd like to access our files from a remote machine. The easiest way to do this is to start a svnserve server. To run it in the background on your computer you type svnserve -d where the -d option will make it run in the background as a deamon. If you want to be slightly safer, run svnserver -d -r /svn to restrict svn access to the /svn tree. Finally, you can specify a specific port by running svnserve -d -r /svn --listen-port 8001
  7. To check out something from a remote machine, you make a directory, say tmp, into which you want to checkout the files, cd into it and run svn checkout snv://YOUR_URL:8001/myproject
  8. Now we want to make sure not everybody has access to the repository. We need to edite two files inside the repository. Go to /svn/myproject/conf, and edit the file svnserve.conf so that it contains: [general]
    anon-access = read
    auth-access = write
    password-db = passwd
    realm = myproject
    Now edit the file passwd (to which we've just reffered in the variable password-db) to say: [users] bobby = bobbyspassword where bobby is you or whoever needs access. :-)
  9. So now we're ready. We can now edit the file we checked out above, and then do svn commit EDITEDFILE Note that we might then be asked for a password for the wrong user. Just hit enter, and you'll be prompted for the user name before giving the password corresponding to that user.
  10. Finally, if you need to migrate your svn server from one machine to another, you first do the following on the original machine: svnadmin dump /svn/myproject > tmp and move the tmp file to the new machine. There, you first set up a new svn directory, like above: mkdir /svn/myproject
    svnadmin create /svn/myproject
    svnadmin load /svn/myproject < tmp