hugopereira84
10/27/2015 - 9:16 AM

Create new branch from another

Create new branch from another

If you want create a new branch from any of the existing branch in git, just follow the options.

First change/checkout into the branch from where you want to create a new branch.

For example if you have the following branches like:
master
dev
branch1

So if you want to create a new branch called "subbranch_of_b1" under the branch named "branch1" follow the steps:
1) Checkout or change into "branch1":
$ git checkout branch1

2) Now create your new branch called "subbranch_of_b1" under the "branch1" using the following command:
$ git checkout -b subbranch_of_b1 branch1

The above will create a new branch called subbranch_of_b1 under the branch branch1.
Now after working with the subbranch_of_b1 you can commit and push or merge it locally or remotely.