Chapter 13. Merging vs. rebasing
This chapter covers
- Using CMake’s branching and merging strategy to manage contributions
- Using Homebrew’s rebasing and squashing strategy to manage contributions
- Deciding what strategy to use for your project
As discussed in technique 14 and technique 43, merging and rebasing are two strategies for updating the contents of one branch based on the contents of another. Merging joins the history of two branches together with a merge commit (a commit with two parent commits); and rebasing creates new, reparented commits on top of the existing commits.
Why are there two strategies for accomplishing essentially the same task? Let’s find out by comparing the Git history of two popular open source projects and their different branching strategies.
CMake is a cross-platform build-system created by Kitware. It has many contributors both inside and outside Kitware; most contributions are among those with direct push access to the Kitware Git repository.
CMake’s Git repository is available to access at http://cmake.org/cmake.git. It’s also mirrored on GitHub at https://github.com/Kitware/CMake if you’d rather browse or clone it from there. Please clone it and examine it while reading this chapter.
CMake makes heavy use of branching and merges. Several of the branches visible or implied in figure 13.1 are as follows: