Non-Fast-Forward Merge (--no-ff Option)

Using --no-ff Option for Non-Fast-Forward Merge in Git

Even when the status of branches is the same as the fast-forward case, you may want to create a new commit. If that is the case, you can use the --no-ff option.

The command enforces the creation of the commit shown in the main figure. The merge result becomes almost the same as the case on the previous page; the only difference is that the previous case has commit M4 before the HEAD on the master branch.

We'll explain how the non-fast-forward merge with the --no-ff option works 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 which were already made before. We'll explain the commands and responses in the command line in three steps.

Non-Fast-forward Merge (--no-ff option) Command Line Example