SVN: Version Controlling System

In this post, I provide details about how I personally handle SVN trunk, branches and tags on Mac using command terminal. It will give beginners some explanations on what trunk, branches and tags are, and how to handle them.

SVN (Subversion) is a version management allows you to control and monitor changes to files. It helps you to perform troubleshooting, performance tuning, quick fixes and prototyping without any external devices. Simultaneously, it also helps to maintain the source code control. In a project that is driven by a single developer or in small, agile teams where an entire project set up is too expensive or possible, but there is a need to maintain the code changes under version control, there subversion integration tools offers easier options to source the code control utilizing external devices and intermediate, working copy that are manually managed in the file system.

Working with SVN is somewhat like growing a tree:

  • A tree has a trunk and some branches
  • Branches grow from the trunk, and thinner branches grow from thicker branches
  • A tree can grow with a trunk and no branch (but not for long)
  • A tree with branches but no trunk looks more like a bundle of twigs fallen on the floor
  • If the trunk is sick, so are the branches and eventually, the whole tree can die
  • If a branch is sick, you can cut it, and another one may grow
  • If a branch grows too much, it may become too heavy for the trunk, and the tree will fall down
  • When you feel your tree, your trunk, or a branch is nice looking, you can take a picture of it to remember how nice it was that day

Trunk: A trunk in SVN is main development area, where major development happens. Do NEVER work directly on the trunk, unless you have to deal with a bug, which is quick and easy to fix (a few characters), or if you have to ADD a few files, which hold no logic (like media files: images, videos, css, etc)

Branch: A branch is a “cheap copy” of a subtree (trunk or a branch) of a SVN repository. A branch in SVN where parallel development on different functionalities happens. When a branch is completed and considered stable, it must be merged back to its original copy, that is: back to the trunk if it was copied from the trunk, or back to its parent branch if it was copied from a branch.

Tag: It contains subdirectories of project, each containing one snapshot of the project. Each snapshot represents its public release. In short its only read only working copy of project.

How to create branch

  • Make sure your TRUNK or directory has latest version of code, which you want to use to create branch.
  • Use command to create new branch
     svn copy trunk_source_path branch_path
  • Now go to branch directory and fire
    svn update

    command so svn will download new branch directory.

  • Working with branch is same like your working with trunk. You can add, update or delete file and commit your changes. Other team member can download those changes using update command.
  • Now if your development is done and you want to stable that version. You need merge branch with trunk. Using
    svn merge branch_path trunk_path
  • Once you fire merge command go to trunk folder and update it. Resolve conflict if there is any and commit changes again so trunk will have stable version copy.