Subversion Branching and Merging for Sprints

On my current project, we create a branch at the beginning of each sprint and maintain a clean trunk. All code from the sprint is committed to the sprint branch. At the end of the sprint, we merge the sprint branch into trunk (assuming it passes QA). This is pretty much the same setup as feature branches. Here are a few notes and snippets for this type of setup.

Merging trunk onto the branch

Occasionally we have to commit something to trunk during a sprint. This normally happens if there is a critical bug on the live site(s) that can not wait for the next release.

To merge from trunk to the branch, go to the root of the branch in terminal. Double check we are in the right placing using the pwd (print working directory) command:

  1. $ pwd

This should return something like:
/Users/name/Sites/example/sprint_1

Make sure the code is up to date:

  1. $ svn up

And then run the merge command:

  1. $ svn merge http://example.com/svn/trunk

This will merge everything from trunk onto your local working copy of the branch. Review the changes and then commit:

  1. $ svn co -m "Merged trunk onto this branch"

Merging the branch onto trunk

At the end of sprint, the sprint branch will need to be merged onto trunk after it has passed the QA stage. In terminal, cd to trunk. Make sure trunk is clean with no locally edited files and run svn update.

Make sure we are in trunk:

  1. $ pwd

This should return something like:
/Users/name/Sites/example/trunk

Update trunk:

  1. $ svn up

Merge sprint_1 branch onto trunk:

  1. $ svn merge --reintegrate https://example.com/svn/branches/sprint_1

Note that we are using the reintegrate option. This is important to avoid conflicts. By using this, Subversion will merge changes that are unique to this branch.

Delete the branch

After we have merged with the reintegrate option, we probably should remove the branch.

  1. $ svn delete https://example.com/svn/branches/sprint_1 -m "Removing old branch."

Creating a release tag

Once we have merged our sprint branch onto trunk, we will need to create a release tag, which will then be tested before going live.

To create the release tag, use the SVN copy command as follows:

  1. $ svn cp https://example.com/svn/trunk https://example.com/svn/tags/release_1.21_RC1 -m "Creating release tag 1.21 RC1"

Conquer Drupal 8 Module Development

Don't struggle to conquer Drupal 8 module development. Action packed lessons where you will work along building your own real world modules.

20% launch discount available now!

Find out more


Add new comment