If you want create a new branch from any of the existing branches 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:
So if you want to create a new branch called "subbranch_of_b1" under the branch named "branch1" follow the steps:
Checkout or change into "branch1"
git checkout branch1
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 (note that branch1
in the above command isn't mandatory since the HEAD is currently pointing to it, you can precise it if you are on a different branch though).
Now after working with the subbranch_of_b1 you can commit and push or merge it locally or remotely.
push the subbranch_of_b1 to remote
git push origin subbranch_of_b1