Chapter 11. Rebasing
[ 11 ]
Rebasing
As you know, Git offers two main ways to integrate changes from one branch to another: merging and rebasing. In Chapters 5 and 9 you learned about fast-forward merges and three-way merges, respectively. In Chapter 10, you learned about merge conflicts and found out that they can arise both during a three-way merge and during a rebase. In this chapter, you will learn about rebasing and walk through an example. I’ll introduce the five stages of the rebase process and show you how to resolve merge conflicts during this process. We’ll look at how merging and rebasing differ, and in which cases you may prefer to rebase instead of merge. I’ll also introduce the golden rule of rebasing, which will help you determine when not to rebase. Additionally, you will learn a bit more about the staging area and how to use it as a rough draft space for organizing what you want to include in your next commit. |
State of the Local and Remote Repositories
At the start of this chapter, you should have two local repositories called rainbow and friend-rainbow and one remote repository called rainbow-remote. All three of these repositories should contain the same commits and branches. As usual, when working through the examples in this chapter I recommend that you use two separate text editor windows and command line windows for the rainbow repository and the friend-rainbow repository.
Visualize it 11-1 shows the state of the local and remote repositories ...
Get Learning Git now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.