By default, git will use fast forward when merging a branch. The problem with fast forward is the HEAD will move to the new branch and the branch merging information will be lost after deletion. However, if we specifically forbid the fast forward mode, a new commit will occur with the new branch information when merging. So it will appear in the history of the repository. Now lets use an example to illustrate the procedure of -no-ff merge.

Create and switch to branch feature-1:

git checkout -b feature-1

Now we do some development. For example change the README.md and submit a new commit:

git add README.md
git commit -m "changed README.md"

Then we switch back to master branch:

git checkout master

Start to merge the feature-1 branch, we use --no-ff to disable the fast forward:

# merge feature-1 to master without fast forward
git merge --no-ff feature-1

# merge feature-1 to master without fast forward and commit at the same time
git merge --no-ff feature-1 -m "merge feature-1 with noff"

Now we can delete the branch:

git branch -d feature-1 # delete branch feature-1