Personal tools
You are here: Home Developer Info Creating or deleting a branch
Document Actions

Creating or deleting a branch

by Renata McCoy last modified 2006-12-05 15:33

Overview

Create a new branch in the repository to work on your changes, fixes and new stuff. Please test the changes and only then submit them to the trunk. When you are done with that branch you can delete it, or you can keep working in that branch.


CDAT repository structure

Our CDAT repository consists of subdirectories: trunk, tags and branches. The trunk is the main development  branch. The individual's branshes should go to the branches subdirectory. The tags subdirectory will have the dedicated branches which will be the copies of some repository revision of the CDAT software that went into a particular software release. A 'tag' is just a "snapshot" of a project in time.


Creating a new branch from trunk

We can create a branch 'new-branch' by copying  in the repository the cdat/trunk  branch into a new
branch. Notice that subversion follows what's called a "cheap copies" strategy, it does not actually duplicate any data. Instead it creates a new directory entry that points to an existing tree (like a hard-link). The subsequent copies are "lazy", that is if you commit a change to one file, then only that file changes - the rest of the files continue to exist as links to the original file in the original directory.

svn copy http://www-pcmdi.llnl.gov/svn/repository/cdat/trunk \ 
http://www-pcmdi.llnl.gov/svn/repository/cdat/branches/new-branch \
-m "Creating a private branch of cdat/trunk @ revision 5732"

You can add the current revision HEAD in the message as shown above, this can be helpful when you need to merge the changes to the trunk. If you have a local copy of the repository, just go to your working copy directory, and type

svn info | grep Rev
Revision: 5732
Last Changed Rev: 5731

Creating a new branch from your working copy.

Suppose you checkout the trunk branch and work on it and realized you really wanted to work in your own brunch. You can copy you working directory ('my_working_copy') to the repository and create a new branch.

cd my_working_copy
svn copy my_working_copy http://www-pcmdi.llnl.gov/svn/repository/cdat/branches/new-branch

Deleting a branch

Now suppose you finished all your work in your personal branch and after merging changes back to the trunk, you don't need it anymore and would like to delete it from the repository.
svn delete http://www-pcmdi.llnl.gov/svn/repository/cdat/branches/new-branch \
-m "Removing obsolete branch from the repository"
Commited revison 5733.
Of course, your branch isn't really gone, it's simply missing from the HEAD revision. If you use 'svn checkout', 'svn switch' or 'svn list' with earlier revision number, you will still see your branch. You can also bring it back using 'svn copy -r '

svn copy -r 5732 http://www-pcmdi.llnl.gov/svn/repository/cdat/branches/new-branch \          
http://www-pcmdi.llnl.gov/svn/repository/cdat/branches/new-branch
Commited revison 5734.



Powered by Plone