0

Im currently working on a project for school where I need to use git & github. I'm fairly new to git but know the basic commands for committing, branching and pushing.

Now my question is, how can I create the following branch structure :

master | ---- branch_1 | ---- subbranch_1 ---- subbranch 2

I've already tried a couple of things : first I followed a guide which you can find here but all my branches where on the same hierarchical order. I also exactly followedthis article but here again my branches were on the same level.

Please can anyone help me with this. Thank you in advance.

  • Branch is just a pointer to a commit. There's no hierarchy of branches. – choroba Mar 19 '19 at 20:18
  • 2
    `git checkout master && git checkout -b branch_1 && git checkout -b subbranch_1 && git checkout branch_1 && git checkout -b subbranch_2` – castis Mar 19 '19 at 20:24

1 Answers1

0

As castis says in the comment.

First git checkout master. This puts you on the master branch.

Next, create branch_1 with git checkout -b branch_1, this also switches you to branch_1.

From there you can create subbranch_1 with git checkout -b subbranch_1. But now you are on subbranch_1...

So, you need to go back to branch_1, by running git checkout branch_1 this puts you on branch_1.

From there you can create subbranch_2 with git checkout -b subbranch_2.

You will now be on subbranch_2.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
  • Okay, this is what I achieved so far https://github.com/JensVanhulst/test/network. Is this right or not ? Because the arrows of subbranch_1 and 2 are starting from master and not from branch_1 ? – Jens Vanhulst Mar 19 '19 at 20:42
  • Yes, because it is pointing at the commits, try committing on change into each branch and see what happens. – DaveShaw Mar 19 '19 at 21:04