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 :
1.why all the commits and branches are shown in a straight forwarding line?
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.