If you are reading this post you already know what is SVN. If you don' I recommend you to read
http://subversion.tigris.org/ and
http://en.wikipedia.org/wiki/Subversion_%28software%29
There is also a free and excellent book on subversion at http://svnbook.red-bean.com/
In this article we will quickly set up an SVN server and also demonstrate how to use it.
First and foremost, make sure you have subversion installed on your server and client.
yum install subversion
Create a directory where you will place the repository.
mkdir /var/svn/
Create your project.
svnadmin create /var/svn/myproject
Run the svnserve daemon
svnserve -d -r /var/svn
When the computer restarts make sure svnserve daemon starts. Put the above line in your /etc/rc.d/rc.local file.
echo "svnserve -d -r /var/svn" >> /etc/rc.d/rc.local
Edit the svnserve.conf to implement access control. Let us make sure only authenticated users are allowed to checkout and commit code.
Open /var/svn/myproject/conf/svnserve.conf in a text editor and put the following in the [general] section.
anon-access = none password-db = passwd
Enter the usernames and passwords in the passwd file.
Open /var/svn/myproject/conf/passwd in a text editor and enter the usernames and passwords under the [users] section.
[users] james = secret bond = secret2
We have two users - james and bond with passwords secret and secret2 respectively.
Our SVN server is ready.
Checkout the project as 'james' to the current directory.
svn checkout svn://mane/myproject --username=james .
Note: In the above command I have used the hostname 'mane'. Replace it with the hostname or the IP address of your SVN server.
svn checkout svn://<yoursvnserverhostnamehere>/myproject --username=james .
Enter the password and you should be ready. The system may warn you about password being stored on your disk unencrypted. Type yes for now.
You should see a message like below.
Checked out revision 0.
Create some directories.
svn mkdir trunk svn mkdir branches svn mkdir tags
Commit the changes.
svn commit -m "My first commit"
You should see a message like:
Adding branches Adding tags Adding trunk Committed revision 1.
Congratulations you just made your first commit.
It is better to work in the trunk directory to be able to easily manage branches and release tags. Therefore, ask your users(right now 'bond' only) to checkout trunk.
svn checkout svn://<yoursvnserverhostnamehere>/myproject/trunk --username=bond path/to/directory/
If you create a directory or a file add them and then commit them.
mkdir apple vi apple/juice.php [edit the file and save] touch grape.php svn add apple/ grape.php svn commit -m "my second commit"
To remove a file or directory use svn rm
svn rm grape.php svn commit -m "my third commit"
You just learned how to setup and SVN server and use it too.
I recommend you to read the free book "Version Control with Subversion" to learn more about SVN.
Keep an eye on http://techchorus.net/category/programming/scm/svn for our new blog posts about SVN.
Where to get further help?
Join the IRC channel #svn on irc.freenode.net
Join the subversion mailing lists.
Set up an SVN server for your next project and tell us about your experience.
Post new comment