Example 1 Customized Versions of a Program
Suppose you are working on two programs for two clients. The two programs are virtually identical, but you want to tailor the programs' behavior in one or two files.
To begin, you share one project, $/WORD, to a new project, $/CLIENT2. (If $/WORD has subprojects, you recursively share them as well.) You now have two projects that are identical in every way.
Next, you select the few files you want to tailor in $/CLIENT2 and branch them. Now when you modify these specific files in $/CLIENT2, your changes do not propagate to $/WORD. All the other files, however, are still shared between the two projects. If you modify any of the shared files, the changes will be propagated to Word.
Branching is quick and easy, and powerful. But keep in mind that if you subsequently add a file to one project and then you decide you want to include it in the other project, you'll have to either add or share it into the other. If you delete a file from one project, you have to delete it in the other as well.
Note This technique can also be used when you are supporting one program under multiple platforms, or in any other case where two versions follow each other through time, but retain different code in specified ways.
Example 2 Parallel Versions of the Same Program
Suppose that after your project reaches version 3.1, development proceeds in two different directions. One team is working toward the next major release, the 4.0 version. The other team is working on a maintenance release, version 3.2.
You create a new project, labeled $/PATCH, to represent the 3.2 version. You share and branch all the files into it. You branch because you don’t want the projects to track each other, because versions 3.2 and 4.0 are going in different directions. Accordingly, changes made in one are not automatically reflected in the other.
The projects now proceed in different directions, independent of each other. Later, you may want to merge the version 3.2 changes bug fixes or minor feature enhancements, for example into version 4.0. You will then be able to merge those changes using the "merge branches" command.