By: SethCardoza - Published: 2009-04-07 14:29:52 in Category: Version Control
Creating a new repository with Subversion is simple. Just run the following command on your svn server:
svnadmin create /path/to/svn/example.com
This will create a new, blank repository with the name "example.com". Now you will want to do one of two things, import an existing project, or setup the initial directory structure for your new repository. To import an existing project, simply run the following command:
svn import /local/path/to/existing/project http://svn.example.com/path/to/svn/example.com
Now, if you are not importing an existing project you will want to setup your initial directory structure, most likely in the following fashion.
/path/to/svn/example.com/branches
/path/to/svn/example.com/tags
/path/to/svn/example.com/trunk
All you have to do is, checkout the project, create the necessary directories, and commit them to the repository. A friend of mine created a shell script to automate creating a new svn repository, and setting up the initial directory structure and/or importing an existing project.
By: SethCardoza - Published: 2009-04-02 18:21:26 in Category: Version Control
Tagging and branching with svn are as simple as using the copy command. For this tutorial, I will assume that your repository has the following structure:
/path/to/repository/branches
/path/to/repository/tags
/path/to/repository/trunk
To create a tag of the trunk, run the following command:
svn copy http://svn.example.com/path/to/repository/trunk http://svn.example.com/path/to/repository/tags/snapshot-of-trunk
To create a tag of your current working copy (assuming you are in that directory on your local machine):
svn copy . http://svn.example.com/path/to/repository/tags/working-copy-seth
To tag a branch, say before merging the branch back into the trunk, run the following command:
svn copy http://svn.example.com/path/to/repository/branches/branch-seth/ http://svn.example.com/path/to/repository/tags/snapshot-branch-seth
To create a branch of the trunk:
svn copy http://svn.example.com/path/to/repository/trunk http://svn.example.com/path/to/repository/branches/branch-seth
To create a branch of your current working copy:
svn copy . http://svn.example.com/path/to/repository/branches/branch-seth
Tags should only be used to create snapshots of the repository. No development should be done on a tag, meaning you should never commit code to a tag. Branches are used for development that you do not want to interfere with everyday activity. They can be used for experimental code, code that you may only want to have run on your local machine, but still would like to have the power of version control behind your code. There are many other situations in which you would want to use a tag or a branch. You can read more about subversion and tags and branches on Wikipedia.
By: SethCardoza - Published: 2009-03-06 21:04:02 in Category: Version Control
So you've created a branch for one reason or another, mainly to make sure that the trunk stays stable and doesn't create chaos for the other developers on your team. You've committed several changes to this branch and thoroughly tested them to make sure everything is in working order. Now how do you get them back into the trunk? This is how.
You should have a local copy of the branch since that is where you have done the development.
/local/path/to/repository/branch
Now, if you don't already have a copy of the trunk locally, get one. Navigate to your local copy of the trunk.
/local/path/to/repository/trunk
You will need the revision number of the revision when you created the branch. For the sake of this example, I will say that the branch was at revision 100. Now run the following command to merge the branch into your local copy of the trunk.
svn merge -r 100:HEAD https://svn.example.com/path/to/repository/branch/my-dev-branch
You should now see that the files modified in your branch have been merged in your local copy of the trunk. Some files may be in conflict, and will have a "C" next to them in the file list after the merge command was run. You can also run an svn status to see if any files are in conflict. Resolve all conflicts, manually if necessary. Now make sure everything is working on your local copy of the trunk. If so, check your changes into the trunk.
On a side note, I like to tag the trunk before I merge a branch back into it. It just puts my mind at ease knowing I have a snapshot of a known working copy of the trunk.
By: SethCardoza - Published: 2008-12-21 23:40:23 in Category: Version Control
I recently had to make my first branch on a project using svn. Making a branch is easy enough with svn copy, but where do you go from there? You could check out a fresh copy of the branch from the repository, but you already have the environment setup and working for the trunk copy. There is an easy and elegant solution, and it lies within svn switch. First navigate to your working copy via the command line. Now to switch to a branch, or tag, in the repository, simply type:
svn switch http://svn.example.com/project/path/to/repo/branch .
Your working copy will now be the branch copy, and any committed changes will go to the branch. It is a simple and easy to use command that should speed up your development.