From the git book:
You’ll notice the phrase "Fast forward" in that merge. Because the commit pointed to by the branch you merged in was directly upstream of the commit you’re on, Git moves the pointer forward. To phrase that another way, when you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together — this is called a "fast forward".
However, the side effect of this "fast forward" is that if you have a feature branch with multiple commits you will lose the historical context of the feature when you merge back into master. In other words, the commits wont be grouped together as part of this feature.
with fast forward: x---x---x---x---x---x---x without fast forward: x---x---x x---x---x---x \x--x--x/
The manual way is to git merge --no-ff
Does anyone know how to set this as a default?
By default, the git merge command is a fast-forward merge. A fast-forward merge is possible when there is a linear path from the current branch tip to the target branch.
In the event that you require a merge commit during a fast forward merge for record keeping purposes you can execute git merge with the --no-ff option. This command merges the specified branch into the current branch, but always generates a merge commit (even if it was a fast-forward merge).
Recursive is the default merge strategy when pulling or merging one branch. Additionally this can detect and handle merges involving renames, but currently cannot make use of detected copies. This is the default merge strategy when pulling or merging one branch.
Fast-forward merges literally move your main branch's tip forward to the end of your feature branch. This keeps all commits created in your feature branch sequential while integrating it neatly back into your main branch.
Set the config variable merge.ff
to false
:
git config --global merge.ff false
(Without --global
to limit the effect to the current project)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With