Information Technology Reference
In-Depth Information
CHAPTER 6
Merging Branches
The commands to create and switch branches allow you to fork the project into inde-
pendent development lines. You can create branches, for example, to start new features
in your application or to implement fixes. Sooner or later you will finish a feature or a
fix and then in all probability, you will want to incorporate your efforts into the main
line of development. The process of joining separate branches can be done using two
different techniques. The first one is realized with the $ git merge command. It is the
subject of this chapter. The second is done with the $ git rebase command. We will
postpone this as it is the subject of the next chapter.
Maybe you have noticed that the term merging is not totally new. We have already
used it in Recipe 5-7 to denote the process of joining changes in the working directory
with the branch we switched to. There, the merge was done during checkout. The result
was left in the working directory to be committed. Here in this chapter, we consider
merging different branches together. The result of the merging branches will be stored
and committed, that is, in one of the branches. We will perform merging in clean recipes
that contain no uncommitted or untracked files. After the recipe, the repository will be in
a clean state again.
Here, you will fully appreciate the aliases simple-commit and clone-with-
branches . They will take you to the higher level of abstraction. Instead of using $
git add and $ git commit , together with $ echo foo > bar , we will create
a series of commits with $ git simple-commit . Thus, you will be able to concen-
trate on merging. The aliases work in such a way that conflicts do not occur. This is a
simplified setting, not a real-life scenario, of course. But I prefer to separate merging
and resolving conflicts into two separate steps. Conflicts will be discussed in-depth in
Chapter 9 .
Search WWH ::




Custom Search