You can integrate several branches by using the git merge command.

Consider the situation below. There are two branches: a "bugfix" branch with a few commits coming off the "master" branch.


In this case, merging "bugfix" back into "master" is not much of an issue. That's because the state of "master" has not changed since "bugfix" was created. Git will merge this by moving the "master" position to the latest position of "bugfix". This merge is called a "fast-forward".

Fast-forward merge

In the example below, however, "master" has been updated several times since "bugfix" was branched out. The changes from "bugfix" and "master" need to be combined when a merge is executed on these two branches.

It has advanced more than when a branch is divided

For this sort of merge, a "merge commit" will be created and the "master" position will be updated to the newly created merge commit.

Merge commit incorporating both changes

Even when a fast-forward merge is possible, you could still explicitly force it to merge without a fast-forward merge.

Non fast-forward merge

As shown above, a non fast-forward merge leaves the "bugfix" branch as it is. This leaves you with a clearer picture of the feature/topic branch "bugfix". You can easily find where the feature/topic branch starts or ends and also track the changes that are made to the feature/topic branch.