Branches in Subversion Repositories
Published on 07 Jun 2004Tags #Subversion
For medium to large projects, it is useful to maintain separate copies of the code to represent different stages of the development. These copies are called branches. A common approach is to have a main branch for unstable development where breakage occurs rather frequently. For each release, a separate branch is created from the main branch which is stabilized before the code is deployed. Sometimes changes need to be transferred between branches if development code needs to be included into a stable branch or if bugfixes need to be included into the development branch. This procedure is called merging.
In subversion, branches are represented by copies of a directory structure with a common history. They are created by one of the following command:
-
This command operates on a working copy of the repository and need a separate check in afterwards:
svn copy trunk 1.0
-
Here, the copy is created in the repository:
svn copy URL1 URL2
If you have fixed a bug in the 1.0 stable branch and need to merge it into the development branch, you need to do the following. It is assumed that the bugfix pushed the repository from revision 79 to 80, the branches are called trunk and 1.0 for the development and the stable branch, respectively.
-
Check the changes:
svn diff -r 79:80 URL/1.0 URL/trunk
-
Merge changes:
svn merge -r 79:80 URL/1.0 URL/trunk
In both commands, the -r 79:80
refers to revisions of the stable branch (the first parameter: URL/1.0
).