- Creating a Repository
- Create an SVN User
- Initial File Import
- Running the Daemon
- Checkout Working Copy
- Commit Changes
- Creating A Branch
This document covers the creation, usage and management of the Subversion (SVN) versioning system. The installation of Subversion is beyond the scope of this tutorial, however, to make sure you have SVN installed, use this command.
You should see something like this
If this is good, then Subversion is installed and we can continue. If you need to install Subversion, consult your distro's docs.
To create a repository for your project, select a place where you have write privileges. For our purposes here, we will create a repository for a project name ACL. So lets begin with creating the repository(repo).
svnadmin create ~/svn_repos/acl
The above commands will firstly create a directory to keep your svn repositories, as you may have many projects. Secondly, the svn repository is created. A quick look in the newly created ~/svn_repos/acl directory will show you much has been done by svn already.
conf db format hooks locks README.txt
Creating an SVN user is quite simple. Using your favourite editor, open the file ~/svn_repos/acl/conf/svnserve.conf
In this file you will need to add, or uncomment if already existing, the following lines in the [general] section of the file.
auth-access = write
password-db = passwd
As you will note, we have created the password-db as passwd. So now, we need to create the password file. Once again, with your favourite editor, open the file ~/svn_repos/acl/conf/passwd. There may be several example users commented out. Add yourself to the file. In this instance, the username kevin is added with the password my_password.
Now that SVN is ready for use, lets import your project files into SVN.
With this done, you should see something like this. In this example, two files are imported. A PHP class and a database schema file. These two files will form the trunk of the SVN repository. You will also create two other directories named "branches" and "tags". No need to know why we do this just yet, more on this later, however, the names might be a give away.
Committed revision 1.
In the above command, svn has imported the files in /home/kevin/trunk/acl, and all the sub directories and files, into the repo file:///home/kevin/svn_repos/acl. The -m flag denotes a commit message saying this was the initial file upload.
Thats IT!?. Yup, thats it
Go to your workspace, here we will use ~/workspace, and issue this command
svn co svn://kevin@localhost/acl/trunk
So now your acl repository is checked out, you can begin work. Edit one of the files in your repository, write and quit. Here we make a change to the schema.sql file. Then commit your changes as follows.
svn: Commit failed (details follow):
svn: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options
svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found
What has happend here is that no editor has been specified as the default editor with which to enter commit messages. As the error message suggest, we could use the -m "message goes here" method, or, and this is much nicer, we can specify an editor which will can be used each time a commit is made.
Add the above command to your ~/.bash_profile and you will no longer need to export the PATH or use the -m flag for messages.
Now when you run the commit command you will see something like this
Transmitting file data .
Committed revision 2.
Essentially, to create a branch, we are creating a new copy of the existing trunk, so we are going to use svn copy, to create a copy into the branches directory.