Chapter 5. Branching
Now that you know how to create a repository and commit to a single branch, it’s time to learn about using multiple branches. Branches allow different versions of the same content to evolve independently at the same time, while you periodically recombine the contributions from different branches in a process called “merging.” When you switch from one branch to another, Git updates your working tree to reflect the state of the repository content in the tip commit of the new branch.
A typical use for a branch is to work on a new software feature in isolation, without adding it to the main line of development of the project; these are often called “feature” or “topic” branches. You work on the feature branch while developing that feature, and switch to the master branch to work on the main project (which does not yet contain the new feature code). Periodically, you merge master into your feature branch, so you’re working on up-to-date code and notice and resolve any conflicts. When the feature is ready, you do the opposite: merge the feature branch into master, adding the new code to the main version of the project.
Another use for multiple branches is to continue maintenance on older versions of software. When you release version 1.0 of your product, it gets its own branch. Product development continues, but you may need to apply bug fixes or new features to that version even after you’ve released 2.0, for customers who are still using the older version; the 1.0 ...