The first merger seems to have been quick, and the second is a tripartite merger.
Explanation
Git has two versions of merging: accelerated and tripartite. (There are other versions, but that is not what happened here.) The default behavior is to perform a quick merge whenever possible, and otherwise do a three-way merge.
Fast merging (you can force this behavior with the --ff-only option, which will cause the merge to fail when fast-forward is not possible) can occur when a merge that merges has the current position of a branch in its history. For example:
A - B - C - D <-master \ E - F - G <- branch-a
Excecuting git merge (with default settings) will result in
A - B - C - D - E - F - G <- branch-a <-master
You will also not be able to edit the merge commit because it does not exist. However, as soon as this happens, your other branch diverges from the master (not just forward):
A - B - C - D - E - F - G <-master \ E1 - E2 <- branch-b
Therefore, Git cannot just move the master pointer from G to E2 , because it will save you from changes made to F and G Instead, a three-way merge occurs, which creates a commit that has two parents and also has a commit message. Now the wizard can be moved to this commit. (Note that in this situation, master and branch-b do NOT point to the same commit.
A - B - C - D - E - F - G - H <-master \ / E1 - E2 <- branch-b
If you want to have a linear history, you need to use rebase, but be warned that if anyone else sees that your branch is doing this, this can lead to problems that are beyond the scope of this answer. Using rebase will include two steps, a reboot, and a subsequent merge. So, instead of merging, you first do the following: branch-b , git rebase master . This creates new commits that are copies of old commits, i.e. The same set of changes, information about the author and the message, but new information about the participants and the parent story. (I will call the commits E1 'and E2' in the illustration to indicate that they are just copies.) Old commits will exist until they are garbage collected, but not accessible unless you look at the reflog. )
A - B - C - D - E - F - G <-master \ \ E1 - E2 \ E1' - E2' <- branch-b
Running git checkout master; git merge --ff-only branch-b git checkout master; git merge --ff-only branch-b will now speed up the forwarding of changes to master, thereby giving you a linear history.
A - B - C - D - E - F - G - E1' -E2' <-master <- branch-b