Fast-Forward Merge

What is Fast-Forward Merge in Git

As explained, when you are merging a child branch that is simply ahead of the parent branch (no changes were made to the parent branch after the point when you created the child branch), the git merge command simply brings changes made in the child branch into the parent branch without creating a new commit. This merging approach is called fast-forward merge.

In the fast-forward merge, the status of the branches will shift to the one shown in the main figure. This command moves the HEAD of the master branch forward to the point of the HEAD of Branch_A. The merge command doesn't impact Branch_A. Simply, the master branch becomes the same as the status of Branch_A.

We'll explain the fast-forward merge in more detail with command line examples below.

Command Line Example

The command line image below is a demonstration of the commit and merge actions, which are the same as the upper illustration in the main figure. M1, M2, M3, A1, and A2 are the commit messages that were already made before. We'll explain the commands and responses in the command line in four steps.

Fast-forward Merge Command Line Example
  1. Confirm the original commit history status by running the git log command on Branch_A. You can see that the commit histories and bran