Why does a new git branch have the old history?

Issue

I’m studying design patterns in python and I’m doing version control in git.
The first thing I did was create a branch called "Creational Patterns", in which I made a commit for each one (Factory, builder…etc)
Later I created a new branch called "Structural Patterns" and moved to it. I have been committing to this branch for these patterns. However when I went to see the history of my "Structural Patterns" branch, there are also the creational pattern commits!
I think git is doing fast-forward merges, however I have the following question: Is it possible to have this branch of structural patterns without the commits of the creational patterns branch? or git will always do this automatically.
Thank you very much!

Solution

You switched the branch from your "Creational Patterns" branch. It is a difference, if you start a new branch from your main branch. If you create a new branch it will create a branch from the point you are currently at. (If that is a different branch, it will take that)

You will need to rebase your branch. @torek has a long answer to this on another question. You can look it up here: How to change the starting point of a branch?

Answered By – Fexo

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published