2

I am doing a git course and the git graph extension has been recommended to me. To my colleagues, the extension shows a graph with the different branches as follows:

git_grapg1

But to me all the branches appear in the same line:

git_graph2

I don't understand what I'm doing wrong or how to use the extension. Thank you very much.

4
  • you are doing nothing wrong, if you don't have merge commits it is a straight line, I prefer it that way
    – rioV8
    Oct 5, 2022 at 14:09
  • I am a little confused. Actually if I have done "merge" between two branches with "git merge hobbies" being in master. In that case, shouldn't I go out like my classmates? Thank you"
    – Diego L
    Oct 5, 2022 at 15:29
  • most likely they are fast-forward merges, when there is no commit done on master git does a fast-forward merge
    – rioV8
    Oct 5, 2022 at 15:48
  • You're right. It is a fast-forward merges. I honestly did not know the concept, you have made me learn something new. THANK YOU!!!!!
    – Diego L
    Oct 5, 2022 at 16:58

2 Answers 2

1

Your colleagues' screen shows a real merge commit. Yours seems to be a fast-forward merge. Fast-forward merges are the default when the branches have not diverged. In that case, the branch label can simply be moved to match the other branch's label (i.e. fast-forwarded). Only when branches have diverged, Git must create a merge commit to reconcile the history of both branches.

1

you can use the --graph option

git log --oneline --all --graph

in vs code you can install the extension : enter image description here

there are two ways to merge:

  • fast forward merge: linear graph
  • three-way merge: commit has diverged from the master

try to use this command when you need to merge the branch in the master => disable fast forward (ff) merge:

git merge --no-ff newBranch

Your Answer

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

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