Question: What are the proven practices for branching and merging?

- J.D. Meier, Jason Taylor, Alex Mackman, Prashant Bansode

Answer

When branching, consider the following guidelines:
  • Structure your branch trees so that you only need to merge along the hierarchy (up and down the branch tree) rather than across the hierarchy. Branching across the hierarchy requires that you use a baseless merge, which requires more manual conflict resolution.
  • The branch hierarchy is based on the branch parent and branch child, which may be different than the physical structure of the source code on disk. When planning your merges, keep the logical branch structure in mind rather than the physical structure on disk.
  • Do not branch too deeply. Because there is latency involved in merging branches, a deep branching structure can mean that changes in a child branch might take a very long time to propagate to the main branch. This can negatively impact project schedules and increase the time required to fix bugs.
  • Branch at a high level, and include configuration and source files.
  • Allow your branching structure to evolve over time to suit changing needs.
  • Do not branch unless your development team needs to work on the same set of files concurrently. If you are unsure, you can label a build and then create a branch from the labeled build at a later point. Merging branches can be costly, especially if there are significant changes between them.
  • Merging requires one or more developers to execute the merge and sort out conflicts. The merged source must be thoroughly tested because it is not uncommon to make bad merge decisions that can destabilize the build.
  • Merging across the branch hierarchy is especially difficult and requires you to manually handle many conflicts that could otherwise be handled automatically.

Additional Resources


Last edited Jul 18, 2007 at 10:12 PM by jtaylorsi, version 5

Comments

RichardBerg May 3, 2007 at 8:21 PM 
Don't miss http://www.codeplex.com/BranchingGuidance/