git merge --no-ff <branchname>

Merge branch without fast-forwarding

This command merges the specified <branchname> into the current branch, but instead of performing a fast-forward merge, which could potentially lose the branching history, it creates a new commit object, thereby preserving the history of independent lines of development.

The --no-ff flag prevents the 'fast forward' behavior.

It's worth mentioning that --no-ff is the long version of the -n flag. Also, if you need to resolve a merge conflict, you can use the -X flag followed by the appropriate strategy such as ours, theirs or ignore-all-space.

Sign in to enable bookmarking, reminders, progress-tracking and more...