I got back on an old project and I ran the nice git status
to figure out what was going on and I noticed way too many branches! I want to do some housekeeping before starting to work on this again but I'm not sure which branch comes from which..
E.G. Does "branchA" derive from "develop"? Does "branchB" derive from "master" or "branchA"??
How can I answer the sample questions above?
Take a look at config file, perhaps there is branch. <branchname>. merge entry, which would tell you what branch this one is based on. You can also try git show-branch <branch> master , as an alternative.
The definition of a branch is a part of a plant stem or a part of something which is larger and more complex. An example of branch is the limb of a tree. An example of branch is the police force as a part of a community's government. Branch means to divide into separate parts or to expand the scope.
The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.
git merge-base shows the commit that is the common ancestor of two branches.
Simple usage: git merge-base <branch> <branch>
shows the common commit of the two branches.
There's no canonical answer for this, since branches are simply pointers to certain commits in a DAG. For instance, master
and foo
could be pointing at the same commit; if you then create a branch from foo
, it's effectively the same as creating a branch from master
.
That said, if you visualize the commit graph (via gitk
or some other graphical history tool), you can get a general sense of where the branch points are in the commit graph, versus where various branch pointers are pointing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With