Chapter 5. Merging
[ 5 ]
Merging
|
In the last chapter, you learned about branches, and we discussed how they allow you to work on the same project in different ways and to collaborate with other people on a project. In this chapter, you are going to learn about integrating changes from one branch into another. In Git, there are two ways to do this: merging and rebasing. We will cover rebasing in Chapter 11; for now we will focus on merging. This chapter will introduce the two types of merges (fast-forward merges and three-way merges), and you will carry out a fast-forward merge. In the process, you will also learn about how Git protects you from losing any uncommitted changes, how changing branches may change the contents of the working directory, and how to check out commits directly. |
State of the Local Repository
At the start of this chapter, you should have three commits and two branches in your rainbow repository, and you should be on the feature branch. The current state of the rainbow repository is illustrated in Visualize it 5-1.
|
[ Visualize it 5-1 ] |

|
The rainbow repository at the start of Chapter 5, with three commits and two branches |
Introducing Merging
In Chapter 4, you created your first branch, feature, and started working on that branch. Branches are a powerful feature of Git, and it’s great that they allow us to work on different ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access