Using gitk log, I could not spot a difference between the effect of git merge and git merge --no-ff. How can I observe the difference (with a git command or some tool)?
Using gitk log , I could not spot a difference between the effect of
Share
The
--no-ffflag preventsgit mergefrom executing a “fast-forward” if it detects that your currentHEADis an ancestor of the commit you’re trying to merge. A fast-forward is when, instead of constructing a merge commit, git just moves your branch pointer to point at the incoming commit. This commonly occurs when doing agit pullwithout any local changes.However, occasionally you want to prevent this behavior from happening, typically because you want to maintain a specific branch topology (e.g. you’re merging in a topic branch and you want to ensure it looks that way when reading history). In order to do that, you can pass the
--no-ffflag andgit mergewill always construct a merge instead of fast-forwarding.Similarly, if you want to execute a
git pullor usegit mergein order to explicitly fast-forward, and you want to bail out if it can’t fast-forward, then you can use the--ff-onlyflag. This way you can regularly do something likegit pull --ff-onlywithout thinking, and then if it errors out you can go back and decide if you want to merge or rebase.