Home > Software engineering >  why all the commits and branches are shown in a straight forwarding line
why all the commits and branches are shown in a straight forwarding line

Time:02-10

as a sample i take these steps :

git branch -b newFeature
git add -A
git commit -m `my feature added`
git checkout master
git merge newFeature

when i do git branch the branches are listed correctly
i expect the branches to be like this :
branching

1.why all the commits and branches are shown in a straight forwarding line?
git
2.how to achieve the mentioned branching?

CodePudding user response:

Because git merge will do fast-forward (--ff) merge when possible by default. A fast-forward merge is possible when the two branches are not diverged. To get the branch graph like you expected, use --no-ff:

git merge --no-ff newFeature

From the docs:

With --no-ff, create a merge commit in all cases, even when the merge could instead be resolved as a fast-forward.

  • Related