Skip to content

WorkingWithSvnBranches

PavelKryukov edited this page Sep 30, 2015 · 1 revision

Intro

What is a branch?

One of the features of version control systems is the ability to isolate changes onto a separate line of development. This line is known as a branch. Branches are often used to try out new features without disturbing the main line of development with compiler errors and bugs. As soon as the new feature is stable enough then the development branch is merged back into the main branch (trunk).

Another feature of version control systems is the ability to mark particular revisions (e.g. a release version), so you can at any time recreate a certain build or environment. This process is known as tagging.

Does svn support branches?

Subversion does not have special commands for branching or tagging, but uses so-called “cheap copies” instead. Cheap copies are similar to hard links in Unix, which means that instead of making a complete copy in the repository, an internal link is created, pointing to a specific tree/revision. As a result branches and tags are very quick to create, and take up almost no extra space in the repository.


Branches in our project

Rules and policies

We have several special places to create branches in our svn. The three following folders can be used:

  • issues -- feature development
  • sandbox -- a room where you are free to create branches there
  • simmy -- development of a very simple education simulator
They are located into http://mdsp.googlecode.com/svn/branches/2011/ (see [this page](IntroductionToTheDevelopmentProcess#Our_SVN_structure.md) for more information on the svn structure of our project).

The name of your branch folder should begin from the first letter of your name and your surname. For example, for Alexander Titov it will be atitov. Then the brief description of your branch goes (words are separated by underscores), i.e. a full name should be something like: atitov_issue_56, atitov_ports, atitov_scheduler_optimization, etc.

When you commit changes into your branch you have to add [branch] prefix in the beginning of your comment. See this page for more information on commit prefixes.

Creating a branch

First of all you should decided which files will be copied into your branch folder. Usually a whole trunk is copied as copying is almost free for svn. However, it is a good style to copy only those files that you need. Don't worry to forget something you will be able to copy it later.

Then think up a name for your branch folder. It must follow our rules presented above.

After that you just have to copy selected files. The copy process depends on the system you are using.

On Unix/Linux

Use the following svn command to create the branch folder and copy a file/folder into it:

svn copy <folder_to_copy> http://mdsp.googlecode.com/svn/branches/2011/<name_of_your_branch_folder> \
    -m "[branch] <reason_to_create_a_branch>"

For example, if I want to create a branch folder with the name atitov_ports and to copy source folder there, I have to enter the following command staying in trunk folder:

svn copy source http://mdsp.googlecode.com/svn/branches/2011/atitov_ports \
    -m "[branch] create a branch for experiments with the ports"

If you want to add something else into your branch folder just use the same command:

svn copy <one_more_folder_to_copy> http://mdsp.googlecode.com/svn/branches/2011/<name_of_your_branch_folder> \
    -m "[branch] <describe_what_you_added>"

On Windows using TortoisSVN

Note! Even if you work on Windows read the previous section.

Right click on the folder you want to copy, then select TortoiseSVN -> Branch/tag. In the appeared window enter http://mdsp.googlecode.com/svn/branches/2011/<name_of_your_branch_folder> into "to URL" field, select "HEAD Revision in the repository", enter a proper comment into "Log message" field and press "OK".

For example, if I want to create a branch folder with the name atitov_ports and to copy source folder there, the window will be look like:

https://mdsp.googlecode.com/svn/wiki/images/creating_branch_in_tortoise_svn.png

Checkout of a branch

To start work with your branch (i.e. add files, commit changes and so on) you have to checkout it. The procedure is absolutely the same as for checkout of the trunk, but you have to use URL of your branch folder (https://mdsp.googlecode.com/svn/branches/2011/<name_of_your_branch_folder>) instead of URL of the trunk folder (https://mdsp.googlecode.com/svn/branches).

Warning! Don't checkout your branch into the folder where you checkouted the trunk. It won't work!
Clone this wiki locally