Chapter 7. Branches

A branch is the fundamental means of launching a separate line of development within a software project. A branch is a split from a kind of unified, primal state, allowing development to continue in multiple directions simultaneously and, potentially, to produce different versions of the project. Often, a branch is reconciled and merged with other branches to reunite disparate efforts.

Git allows many branches and thus many different lines of development within a repository. Git’s branching system is lightweight and simple. Moreover, Git has first-rate support for merges. As a result, most Git users make routine use of branches.

This chapter shows you how to select, create, view, and remove branches. It also provides some best practices, so your branches don’t twist into something akin to a manzanita.[17]

Reasons for Using Branches

A branch can be created for a countless number of technical, philosophical, managerial, and even social reasons. Here is just a smattering of common rationales:

  • A branch often represents an individual customer release. If you want to start version 1.1 of your project but you know that some of your customers want to stick with version 1.0, keep the old version alive as a separate branch.

  • A branch can encapsulate a development phase, such as the prototype, beta, stable, or bleeding-edge release. You can think of the version 1.1 release as a separate phase, too—the maintenance release.

  • A branch can isolate the development of a single feature or research into a particularly complex bug. For example, you can introduce a branch for a well-defined and conceptually isolated task or to facilitate a merge of several branches prior to a release.

    It may seem like overkill to create a new branch just to fix one bug, but Git’s branching system encourages such small-scale use.

  • An individual branch can represent the work of an individual contributor. Another branch—the integration branch—can be used specifically to unify efforts.

Git refers to a branch such as those just listed as a topic branch or a development branch. The word topic simply indicates that each branch in the repository has a particular purpose.

Git also has the notion of a tracking branch, or a branch to keep clones of a repository in sync. Chapter 11 explains how to use a tracking branch in detail.



[17] OK, OK. It’s a small, bushy tree, a highly branched shrub-thing. Perhaps a better analogy is a banyan tree.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.68.50