Friday 20 September 2013

Branching an SVN repository

SOURCE: 

http://bytealmanac.wordpress.com/2013/04/16/branching-an-svn-repository/

 

Branching an SVN repository

Branches are required in the following scenarios:
  1. When you want to work parallelly on two separate versions of the code, both of which might undergo separate development.
  2. Or, when you are not sure about the current experimental changes that you’re making to your code. You want to try out some stuff, and if everything works as you expected, use this as the mainline code base; otherwise, if things do not work out, you can come back to the last known good state.
Here is how to branch your code that resides at http://svn.myrepo.com/project.
  1. Go to the working directory (that’s the folder where the root of your code base resides).
  2. Create a folder branches/ inside the working directory.
  3. Add and commit this new folder:
    svn add branches
    svn commit -m "Added branches"
  4. Branch the code base by copying the current version to a new folder inside the branches folder in the repository.
    svn copy http://svn.myrepo.com/project http://svn.myrepo.com/project/branches/mybranch
Now that the repository has been branched, what do you need to do on your local machine? There are two options:
  1. Keep the old version (usually called the trunk) intact in the current working directory and check out the branch to a new folder:
    1. Create a new folder mybranch
    2. svn co http://svn.myrepo.com/project/branches/mybranch mybranch
  2. Delete the contents of the current folder (working directory) and work exclusively on the new branch (this is called a switch):
    svn switch http://svn.myrepo.com/project/branches/mybranch .

No comments: