Branching makes it easy to defer concerns about the impact of a change on the main code line and to focus on the code variant you are working on. By working on a branch to deliver a fix, for example, you address the following concerns:
- The perception that it’s too costly to QA the new code line before delivery and that making a small change to “stable” code will be easier to validate.
- The desire to limit the visibility of new (incomplete) features, since new work is being done on the main line.
Another example is using staged integration branches, where a change does not appear in the main line until it has passed through a variety of merges. In this case, you are using branching to make it less likely that someone will check out broken code from the main line.
While these approaches have merit on the surface, you also must think about the basic problem that you are solving and consider the costs of working on a branch.
The Distractions of Branching
When working on a branch, you are splitting your attention between multiple streams of work. There is a context switch to working on the “old” code from the branch, and often the changes you make on a branch (or equivalent functionality) need to be merged to the main code line. Doing this merge creates extra work over what you might do if you are able to simply change the main code line.
A branch can be a useful tool in some situations, allowing your team to respond to issues with agility even when your main code line is not agile enough to allow the change. A branch can help you be more agile by allowing you to focus on a task, or it can impair agility by causing a split in attention.
The paradox of branching is that while branching is meant to help you to focus, a branch can be a source of distraction to the team for reasons ranging from context shifting to confusion about where a change was made. To using branching effectively, you need to acknowledge the potential distractions a branch can cause and determine whether the net effect of creating a branch is more focus for the team. If it is not, you should find a different approach to address the problem.