1 / 3
Caption Text
2 / 3
Caption Two
3 / 3
Caption Three margin testing

Monday, June 21, 2010

Creating Local SVN Repository (Home Repository) for a Single Developer

http://www.guyrutenberg.com/2007/10/29/creating-local-svn-repository-home-repository/
(I followed these steps on PigU, HL 20100621)

In this tutorial I will explain how to create a local Subversion (SVN) repository, intended for a single user. I assume that you already know the benefits of keeping track of old revision of projects or important documents such as a resume or a thesis you have been writing. Subversion offers you a very convenient yet strong method to do so, and the easiest way to do so with Subversion (SVN) is to create a local, home, repository intended for a single user – you. The repository we are going to create will be used by a single user, working locally on the machine. In this tutorial I will assume the repository will be created for a project called "project1″. "project1″ can be a real project you are doing, a paper you are writing or any thing else that can be stored under revision control (that almost everything).

Creating the repository

We will start by creating the repository. From the command line do the following:

 $ mkdir /home/user/svnrep 
 $ cd ~/svnrep 
 $ svnadmin create project1

In the first line we create a directory to house all of your repositories (I assume you are working under the username "user"). I prefer to use different repositories for different projects that are unrelated, no matter how small they are. Because I use many repositories, I prefer to have a single directory underneath all repositories will reside in an organized way (i.e. no junk files or any other kind of stuff except directories). Next thing, is to cd into the directory we created, and actually create the repository using the svnadmin command. To repository we've created is called "project1″.

The brand new "project1″ repository is currently empty and in revision 0. This will change once we put some data in it. The first thing you do with a new repository is to import initial project data into it.

 $ svn import /home/user/project1 file:///home/user/svnrep/project1/trunk -m "Initial import of project1"

Will import the current project1's file into the repository (assuming that project1 indeed resides in/home/user/project1). The trunk appended to the end of the repository URL, is part of the directory layout convention used by many Subversion users. The last part of the command is the message that will be attached to the import in the SVN log.

Now the repository holds data and you are ready to checkout the code from it, and start working.

Checkout a Working Copy and Start Working

When using SVN (as well as in most revision control systems) you don't work directly on the repository. Instead you checkout a working copy from it, and work on this copy. To checkout a working copy from the repository, use:

 $ svn co file:///home/user/svnrep/project1/trunk /home/user/project1_work

This will create a working copy of the repository under /home/user/project1_work. You can edit this copy safely.

After you've done editing your working copy, you will want to commit those changes back to the repository. Assuming you are already inside the directory of the working copy, just do:

 $ svn commit -m "Some log message"

This will send you changes back to the repository and store them there. Change the "Some log message" to some useful short description of the changes you've made.

Some Useful Commands

To view a list of log messages that were attached to the operations on the repository, use:

 $ svn log $ svn log -r 5:HEAD

The first command will print all log messages. The second command will print the log messages from revision 5 to the latest revision. You can substitute the HEAD with a number to get the log messages of the revisions up to a specific one.

To view the changes you made before committing your code, use:

 $ svn diff

Another important command is the one to update your working copy with the latest revision from the repository. This can be done using:

 $ svn update

However, since your are the only user of the local repository, you won't have to use this function often (if at all), unless you use two, or more, working copies for your project.

This concludes this tutorial. I hope you know by now how to create and use, a single user local SVN repository.

No comments:

Post a Comment

Featured Post

Windows和Ubuntu双系统完全独立的安装方法

http://www.ubuntuhome.com/windows-and-ubuntu-install.html  | Ubuntu Home Posted by Snow on 2012/06/25 安装Windows和Ubuntu双系统时,很多人喜欢先安装windows,然...