4

Test case:

                 A---B---C topic
                /
           D---E master

If I do

git checkout master
git merge topic

I'll get


               D---E---A---B---C master,topic

How can I merge so that the commit graph remains like the following

                     A---B---C topic
                    /         \
               D---E-----------F master
1

1 Answer 1

6

For a one-shot approach, you can do

git merge topic --no-ff

and it will force the merge commit (see doc).


But also note that if you need to have that on a repo as part of your general workflow, you can set it in your config to never fast-forward merge even when possible, with

git config merge.ff false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.