Merge Branches

[article]

in both directions.  For example:

  1. Create a branch
  2. Do some work in both the branch and the trunk
  3. Merge some changes from the branch to the trun
  4. Do some more work
  5. Merge some changes from the trunk to the branch

At step 5, when it comes time to select changes to be merged, you want the changes from step 3 to be ignored.  There is no need to merge those changes from the trunk to the branch because the branch is where those changes came from in the first place!  A source control tool with a smart implementation of merge history will know this.

Not all source control tools support merge history.  A tool without merge history can still merge branches.  It simply requires the developer to be more involved, to do more thinking.

In fact, I'll have to admit that at the time of this writing, my own favorite tool falls into this category.  We're planning some major improvements to the merge branches feature for Vault 4.0, but as of version 3.x, Vault does not support merge history.  Subversion doesn't either, as of version 1.1.  Perforce is reported to have a good implementation of merge history, so we could say that its "slider" rests a bit further to the left.

Summary

I don't want this chapter to be a step-by-step guide to using any one particular source control tool, so I'm going to keep this discussion fairly high-level.  Each tool implements the merging of branches a little differently. 

For some additional information, I suggest you look at Version Control with Subversion , a book from O'Reilly.  It is obviously Subversion-specific, but it contains a discussion of branching and merging which I think is pretty good. 

The one thing all these tools have in common is the need for the developer to think.  Take the time to understand exactly how the branching and merging features work in your source control tool.


Eric Sink is a software developer at SourceGearwho make source control (aka "version control", "SCM") tools for Windows developers. He founded the AbiWord project and was responsible for much of the original design and implementation. Prior to SourceGear, he was the Project Lead for the browser team at Spyglass (now OpenTV) who built the original versions of the browser you now know as "Internet Explorer". Eric received his B.S. in Computer Science from the University of Illinois at Urbana-Champaign. The title on Eric's business card says "Software Craftsman". You can Eric at

About the author

TechWell Contributor's picture TechWell Contributor

The opinions and positions expressed within these guest posts are those of the author alone and do not represent those of the TechWell Community Sites. Guest authors represent that they have the right to distribute this content and that such content is not violating the legal rights of others. If you would like to contribute content to a TechWell Community Site, email editors@techwell.com.

AgileConnection is one of the growing communities of the TechWell network.

Featuring fresh, insightful stories, TechWell.com is the place to go for what is happening in software development and delivery.  Join the conversation now!